Share Application-Scoped Data in Web Farm or Web Garden

Posted by Hugh Ang at 4/24/2007 02:37:00 PM

I was asked recently on how to share application-scoped data in a web farm or web garden. The answer would have been easy if the question had been on session data as ASP.NET offers a couple of different ways for sharing session out-of-proc based on configuration, namely, by setting mode attribute to "StateServer", "SQLServer" or "Custom" in the sessionState element of the web.config file.

For sharing application-scoped data arocess processes, though, there is no such feature provided out of box by ASP.NET. Back when EntLib wasn’t available, I implemented a custom caching framework to share application-scoped data in the web farm. Now with EntLib, you can use the caching block to achieve this quite easily. You just need to choose the database cache storage or a custom storage for the caching block. The custom storage, if you choose to do so, will have to be written and plugged into the EntLib framework of course. As the objects put in the cache will be serialized across processes and may be saved in the database, the objects will need to be serializable.