Using ASP.NET Cache in Web Farms
ASP.NET has now become a really popular technology for web apps and more and more people are developing high traffic applications in it. And, to handle higher traffic, these ASP.NET apps are deployed in load balanced web farms where you can add more servers as your traffic load increases. So, it is very scalable except for one problem.
And, that problem is the database and your data storage which cannot scale in the same fashion to handle the higher traffic loads. So, what you get very quickly is a bottleneck where your ASP.NET application slows down and can even grinds to a halt.
In such situations, data caching is an excellent way of resolving this database and data storage bottleneck. Caching allow you to cache application data close-by and reduce those expensive database trips.
What is ASP.NET Cache?
ASP.NET Cache allows you to cache application data and is actually a fairly feature-rich cache including the following features:
Expirations: Automatic absolute and sliding expirations
CacheDependency: To manage data relationships in the cache
SqlCacheDependency: To synchronize cache with database
Callbacks: To be notified when items are updated in cache
ASP.NET Cache Limitations in Web Farms
Despite very useful caching features, ASP.NET Cache has some serious limitations. They are:
Does not synchronize across server or worker processes: It does not synchronize across multiple servers or even multiple worker processes. So, you cannot use it in a web farm or even a web garden unless your data is read-only whereas you need to cache all kinds of data, including one that changes somewhat frequently.
Cache size limitation: You cannot grow the ASP.NET Cache to be more than what one ASP.NET worker process can contain. For 32-bit systems, this is 1GB and that includes app code as well. Even for 64-bit systems, the size cannot scale.
Use ASP.NET Cache Compatible Distributed Cache
The way to work around these limitations of ASP.NET Cache is to use a distributed cache like NCache for web farms. NCache provides the same features that ASP.NET Cache plus more. But, as a distributed cache, NCache easily synchronizes across multiple servers.
Here are some benefits you get from NCache:
Scales transaction load very nicely: You can keep adding more cache servers to the cache cluster as your web farm grows from 2 to 200 servers. NCache never becomes a bottleneck in handling more traffic.
Scales data storage nicely: As you add more cache servers, your cache storage capacity grows due to Partition Cache topology.
Replicates data for reliability: You can ensure that no data loss occurs even if a server goes down because data is replicated to other servers.
Dynamic self healing cache cluster: NCache provides 100% uptime through this. And, you can add or remove cache servers at runtime without stopping the cache or your application.
Well, if you have an ASP.NET application running in a web farm, take a look at NCache and see how it will help improve your application’s performance and scalability.
cameronMember Since 14 Jul 2011
Offline Last Active Sep 07 2011 12:57 AM