1

I have created this web application in ASP.NET. The application was originally developed in MVC3 on VS2010, but recently we have migrated it to VS2012 MVC4.

The reason for the migration was that we needed to use SignalR which is supported in MVC4 and OS win 8. (SignalR works in the earlier version, I'm aware of that, but it uses the fallback method. Hence we had to migrate.)

We are also using Fluent Nhibernate. And it's currently locally hosted on IIS 8.

Now here's the question. The application loads perfectly the first time. In fact, it does so for the first few requests. But after a few requests it replies too slow. And sometimes it just crashes. Refreshes always crash.

Has anyone else come across such problem?

Any help will be really helpful. Thankx :)

EDIT:

Something like what this guy here is facing but it happens for me only after few requests Why is the ASP.NET/Visual Studio Web Development Server so slow?

Community
  • 1
  • 1
Agnes Simpson
  • 303
  • 1
  • 3
  • 13
  • Define "crash"? Define "slow"? Where does the slowness come from? What do Fiddler, YSlow, your logging and tracing say? This question is too broad for SO. There is no _"Oh, MVC is slow unless you add ``"_ answer. _You_ will have to pinpoint the cause of the issue, be it a database call, a file lock, loads of HTTP requests, a faulty disk or whatever. – CodeCaster Jun 28 '13 at 12:03
  • Do you have issues with performance only when working with the database? NHibernate sometimes can affect performance significantly when configured inappropriately. – Andrei Jun 28 '13 at 12:03
  • Things generally don't "just crash" unless there's some sort of hardware failure. What is the error? Chances are there's an exception being thrown somewhere, what is it? What is the code that throws it? What are the runtime values for that code when it happens? When it's slow, what is the bottleneck? What code is waiting, and what is it waiting for? – David Jun 28 '13 at 12:05
  • Yep! What is the error? and welcome to stackoverflow :) – Andrei Jun 28 '13 at 12:06
  • Ok i hv configured nhibernate to disable lazy load. I know that would affect the performance to an xtent. But if was bcoz of that it would have been slow after the debugging starts. The time taken is before the debugging start. – Agnes Simpson Jun 28 '13 at 12:09
  • It doesnt show any error.. like an ASP error page or nything. The browser just doesnt load the URL after some requests. – Agnes Simpson Jun 28 '13 at 12:12

1 Answers1

2

Without seeing any code I can only guess but I had an issue with an application running progressively slower with Fluent NHibernate. Here's two possible things you may be doing wrong:

Make sure the session factory exists for the entire length of the application. For example I have the following code (using Microsoft Unity) to register my dependency:

builderContext.Container.RegisterType<ISessionFactory>(new ContainerControlledLifetimeManager(), new InjectionFactory(c => {
    return BuildSessionFactory();
}));

Secondly make sure you close the NHibernate session after every request. For example say you store the session in HttpContext.Current.Items, then in the Application_EndRequest event (in the Global.asax file) you would say something like:

var session = HttpContext.Current.Items["NameOfCache"] as ISession;

if (session != null && session.IsOpen)
    session.Close();

The second one is more likely to cause an application to get progressively slower. I hope this helps.

Erik Schierboom
  • 16,301
  • 10
  • 64
  • 81
nfplee
  • 7,643
  • 12
  • 63
  • 124
  • having the 'using' keyword around the session instance is not enough? It'l dispose the session object. Doesnt that also close all the connections related to that instance? – Agnes Simpson Jun 28 '13 at 12:49
  • Calling Dispose (or by using a using block) will call Close so you should be alright. – nfplee Jun 28 '13 at 13:31