How to share a static instance of DataCacheFactory in a whole Web Role for using in multiple websites and so creating only one connection to cache?

StackOverflow https://stackoverflow.com/questions/8271254

Question

I have 15 websites on a webrole, they all use the same azure cache. I only need the 128 MB cache, so it allows me only 10 connections.

Basically if I instance one connection in each website on App_start and store it on the application level, i get (if i understand well) :

  • 15 connexions to cache x number webrole instances

So with 2 instances of webrole for SLA, with 15 websites each, that create 30 connexions to azure cache. Correct ?

In this thread : http://social.msdn.microsoft.com/Forums/en/windowsazuredata/thread/216a5159-0186-403c-89d8-99058d51a542

one guy states: "Your web role could have a static instance of DataCacheFactory which can be used by all the websites"

That mean instead of having one cache connection for each website I could have only one per webrole, that is only 2 connections to azure cache that means 128 MB plan would fit perfectly.

So, anyone know how to set a static instance of DataCacheFactory which can be used by all the websites in a webrole ?

Était-ce utile?

La solution

Initialy I thought that the challenge here is that each web site will run on its own application pool (i.e process) and static members cannot be shared across processes. If this was the case, I thought, a possible solution could be to configure the various web sites to run under the same application pool.

This comes at a cost, but actually is also irrelevant - even with the web sites running under the same application pool they will each have their own AppDomain, and so you would still not be able to share static members.

Given that - I'm pretty sure that sharing a static member between different web sites (or even virtual directory, essentially - two different applications on IIS) - is not possible, as it would competely defeat the point of having separate applications.

This has nothing to do with Azure per-se, but rather and IIS behaviour.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top