My previous setup was the only web server and the only database server. I used nhibernate level 2 caching for caching to avoid a lot of calls going to the database. This works great since I used this assembly
nhibernate.caches.syscache
and added this code to enable second level caching (using the regular syscache provider):
return configuration .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ApplicationMap>().Conventions.Add(typeof(Conventions))) .ExposeConfiguration( c => { c.SetProperty("proxyfactory.factory_class", proxyFactory); c.SetProperty("cache.provider_class", "NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache"); c.SetProperty("cache.use_second_level_cache", "true"); c.SetProperty("cache.use_query_cache", "true"); c.SetProperty("expiration", "86400"); }) .BuildSessionFactory();
Now I have moved to a new environment with several web servers, and I am trying to understand the consequences of this (I still have one db server).
Since the cache was stored on the web server before, now it seems that I have two parallel caches on each web server, which themselves may not synchronize and may cause outdated updates, etc.
What is the best solution to get the benefits of caching that I had before, but also took advantage of the fault tolerance of the web server load balancing that comes with this new setting?
asp.net-mvc nhibernate fluent-nhibernate load-balancing second-level-cache
leora
source share