Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate vs Entity Framework 6 performance for big number of users [closed]

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!
like image 572
Zilberman Rafael Avatar asked Jan 11 '14 07:01

Zilberman Rafael


People also ask

Is NHibernate better than Entity Framework?

EF Core can use a ROWVERSION/TIMESTAMP column on SQL Server, or any of a list of columns, when updating a record. NHibernate offers richer capabilities, besides SQL Server ROWVERSION/TIMESTAMP, it can also use database native mechanisms such as Oracle's ORA_ROWSCN, but also timestamp or version columns.

Is Dapper faster than NHibernate?

NHibernate is still faster than ADO and Dapper for everything except the select.

Is NHibernate a framework?

NHibernate is a mature, open source object-relational mapper for the . NET framework. It's actively developed, fully featured and used in thousands of successful projects.

Does Java have something like Entity Framework?

The standard ORM API in Java it's called JPA, and is part of the Java EE specification. Another alternative would be to use Hibernate.


1 Answers

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 ?

like image 191
Beatles1692 Avatar answered Oct 04 '22 13:10

Beatles1692