NHibernate vs Entity Framework 6 performance for big number of users

asp.net-mvc-5 c# entity-framework nhibernate

Question

I'm building big web application that should communicate with the database very often. I'm wondering what library should I use for communication NHibernate or Entity Framework 6?

Here is my application specs:

  • Users: The application built for big number of users, lets start with 100,000 users registered. 50,000 users online, every user can send up to 1 message at second. 15,000 messages got sent every second.
  • Memory: It's very important to keep memory in normal state so I suppose that I should use LazyLoad?
  • The database: The database structure is very complicated.
  • Users engine: Currently I'm using ASP.NET MVC 5 Identity with Entity Framework 6 UserStore.

Important things:

  • The comfort is very important to me!
  • Code First: I hate when code gets generated.
  • Performance: The performance is the most important thing here!
1
14
1/11/2014 12:47:03 PM

Accepted Answer

As someone who is using NHibernate for several years I might not be the right person to help you choose between EF or NHibernate but here are some general pieces of advice that I've learned these years:

-Be in control : I mean choose an ORM that let you control every aspect of its functionality.Fortunately for us , NHibernate is one of them. You can call SPs and other Database objects and map their result to your objects.You can write interceptors to intercept NHibernate functionality and so on.

-Avoid general ORM issues from the start:one of them (which has a big impact on performance) is SELECT N+1.

-Use specific profiler to see how your ORM is working: I think this is really important for us to be able to see how the ORM is working and what queries are actually running in the back.

-Use cache whenever possible: I don't know about EF but Nhibernate has a second level cache mechanism that you can use to cache ferequently read and static data in memory to gain a better performance

-Have a plan for load testing and stress testing your application: No matter which ORM you choose , there will be times that you should increase the performance of your application.I think the best way to see how an application is working on a large scale is to somehow simulate it and try to tweak it so that it works in its best condition.

-Have a Plan B : ORMs are designed to help us to solve the dilemma of storing data in tables and using them as objects in our application.Thus they are doing something extra for us and they tend to be slower than using data in tabular format.So there are times that it would be better to use a plain tabular format in our application instead of converting it to objects (Take showing a list of information for instance)

P.S. This might be off topic but have you consider using a NoSql database instead of a relational one ?

8
1/12/2014 8:05:11 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow