How to share variable between all instances of worker process asp.net

1k Views Asked by At

I had To move a pre built asp website from single worker process environment to multiple worker process environment on cloud servers. I was having a class with static arraylist variable which use to contain last 2 minutes of all session information for tracking purpose. The admin use to access this arraylist to view live reports. But on moving it to cloud infrastructure this has breaked down results are no longer correct. It depends on which server behind load balancer is serving the pages thus we have multiple instances of the static variable per app pool. I tried to move to mysql but we needed to flush out data regularly and it was also having performance issue. Here the arraylist is processed heavily to churn out useful data thus I need something which is inmemory.

Please note that before also the use of static variable without lock was the downside but that only led to difference between 1 or 2 records but was blazing fast.

1

There are 1 best solutions below

0
On

You can consider backing your session by SQL server based session storage. Alternatively you can use a application caching server to back it. That will let you share it across multiple web servers.