Question

My ASP.NET application stores some expensive (to load) data in an application-accessible static field (using System.Web.Caching.Cache is inappropriate in this case).

My application is also load-balanced across a couple of webservers with a central SQL Server on another machine.

There are times when this cache will be invalidated. If the user submits some updated data on Server01 then that application knows about it can will clear its local cache when it also submits the data to the database.

However, how can Server01 notify Server02 of this change so Server02's cache will be invalidated?

I'm not aware of any built-in inter-server IPC in ASP.NET for web-farm communication, it seems that I would have to create a URI handler in the application (e.g. http://mysite/InvalidateCache) that would be called by the other server, but it seems a bit hackish. Is there a better way?

Was it helpful?

Solution

I was having a bit of a brain-fart and realized that web-servers can communicate between each other simply by sending each other requests - there is no need for a special side-channel line. I earlier call the idea hackish, but it's sound in theory.

Obviously for security purposes these requests need to go through a physical private network connection, or have cryptographically signed requests, but I really can't think of anything wrong with that approach now.

OTHER TIPS

I would suggest you explore a distributed cache like AppFabric. http://msdn.microsoft.com/en-us/library/ff383731(v=azure.10).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top