Cross-server communication in load-balanced ASP.NET web application

asp.net, caching, invalidation, ipc, web-farm

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.

Problem

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?

Original source