I am developing my first application using mmc3 nhibernate orm layer with mssql db.
This is my first application created using nhibernate, and everything is fine except for intuitive time. After some research, I completed a session for each web request, which is certainly an update, my objects load much faster after the first call, but my problem remains the same.
The initial response time is very slow, when I type domainname.com and press enter, the wait time is approx. 10-15 sec and this is not the actual time for loading the content, after that time 10-15 seconds. my site starts loading, a few more seconds.
This is the time during which the factory session should initialize all the “things” that are needed, but I think it should be something else. This is unacceptable.
My application runs on winhost when allocating memory on a 200 MB site, so I think this is not a problem.
Any hints are welcome. If you need more information, please ask.
thank
Update:
After learning how to use an application session with the nhibernate profiler, I found some interesting material. Since I'm really starting to use the profiler, I think I found an expensive session. In general statistics, 67 objects are loaded in 36.571 durations in seconds. This seconds value is really strange because I have 10-max. 15 seconds to download.
Second update:
global.asax
public class MvcApplication : System.Web.HttpApplication{
public static ISessionFactory SessionFactory =
MyDomain.Infrastructure.SessionProvider.CreateSessionFactory();
SessionFactory.OpenSession();
}
. , :
public static ISessionFactory CreateSessionFactory()
{
string conStringName = "ConnectionString";
var cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey(conStringName)))
.Mappings(m => m.FluentMappings.Add<Entity1>())
.Mappings(m => m.FluentMappings.Add<Entity2>())
.Mappings(m => m.FluentMappings.Add<Entity3>())
.ExposeConfiguration(p => p.SetProperty("current_session_context_class", "web"))
.BuildConfiguration();
return cfg.BuildSessionFactory();
}
3
4
sessionFactory. , . - , , , , . / . .