How to handle ASP.NET application variables in a load balanced web farm

I am moving a site from one server to a server farm consisting of three web servers behind a load balancer. It seems easy enough to handle session management - just make the sessions sticky on the Load Balancer (we appreciated SQL-based session management, but decided to continue using InProc session management to increase efficiency).

However, we also use a significant configuration object that we store in the application space (for example, Application [ObjName]). Since the configuration object is loaded from memory, we have no problem until someone changes the configuration. At this point, the application on the hosting server will have changes, and there will be changes in the database. However, the other two servers will not be affected. We discussed the β€œonce per minute” rule of polling (for example, in new sessions), instead storing information in the session (not very efficiently), etc. Everyone has serious flaws. I wonder what other people are doing. Is it possible to save application space on SQL Server but inproc session space? Any help or understanding on how to handle this will be appreciated!

+4
source share
2 answers

Application [] will always be based on local memory, so no matter what you intend to make some code changes. So put it somewhere else like distributed cache, AppFabric , NCache , memcached.net , etc. When someone makes changes to the cache configuration update, when you need to read the settings read from the cache. Advocacy / synchronization is done by the cache itself.

+3
source

Currently, we have decided to use NCache, since we have 4 web servers for our web farms. This third-party caching tool can work perfectly with a load balancer and is easy to configure (just the Express version is free. For the Professional and Enterprise versions only for developers). It is also very fast and stable. You must configure NChache on each server and configure a load balancer to work with all of them. Hope this helps.

0
source

Source: https://habr.com/ru/post/1401420/


All Articles