2

Recently I programmed an ASP.NET MVC 4 web application using Entity Framework, Razor - quite large (about 90 entities, many forms etc.). Everything worked fine and quite fast in my development environment.

Troubles started in moment of deploying the application on ther server and when more concurrent users started to appear on website. Many users are experiencing very slow load. In some cases it looked like when one user blocking another until his request is completed (logging in, out etc.). I have read about not using Sessions in ASP.NET, but I also read that each user has its own session, it is thead safe, so sessions between themselves should not influence each other. In most cases entity framework queries are only reading data so database locks should not appear often, but I do not really know. However pages became very slow when there are on the server about 20 people at same time.

I need to load / store user profile - column widths, settings, ordering etc. - and use it in views and controllers, that is why i am using session. Session lock should be blocking only concurrent requests of user himself until completed, not the other one, am I right? I also use repeated ajax requests for displaying time-related information. And something in my application causes big hangs when there are more people on the web. When I am alone on the web, everything works fast. I am quite new to this and dont know much where to start digging.

Are there any best practises for avoiding such problems, or any idea about what sort of techniques can cause such problems?

  • 1
    Don't guess where the problem is, profile your application. The number of entities and users you describe is tiny - ASP.NET sites typically serve several thousands of users and complex business applications can have several hundred entities. It's far more likely your data, rendering code is slow, or that your server machine is too slow for the load. How did you design your EF contexts? Are you caching the data? Are you keeping connections and transactions open? Is there contention in the database? – Panagiotis Kanavos Oct 17 '14 at 07:31
  • I am using context generated by visual studio - database first. Mostly just read by linq to list and pass it to the view where is foreach and forms, nothing complicated. I know that in comparison with business app this one is very tiny. Each controller disposes db context at controller disposal, so connections should not stay open. I am caching often used data. What did you mean by contention in the database? – Jaroslav Daníček Oct 17 '14 at 07:38
  • "Nothing complicated" may well mean that you load very wide tables with many rows. Profile your application. Session management is not an issue for such a small application. – Panagiotis Kanavos Oct 17 '14 at 07:42
  • Data amount is mostly quite small - hundreds of rows till now. I tried JetBrains dotTrace but not in time where there were more concurrent users on the web and I guess the results wont be the same. Thank you I will profile again – Jaroslav Daníček Oct 17 '14 at 07:47
  • Instead of doing that, create a load test for your application and profile the test run. – Panagiotis Kanavos Oct 17 '14 at 09:11

0 Answers0