For some time now, we have experinced some strange random timeout problems on various web applications. We have a load balanced environment with up to 6 web servers sitting behind a rather nice load balancer.
In our web applications, session timout is set at the standard 20 minutes. It is also set at 20 minutes in IIS, so everything should work fine.
However, what we have been finding is that on, what looks like a random basis, the session has timed out. Sometimes it's 20 minutes, othertimes it's 5 minutes. The first thing that we looked at was the application pool behaviour to see if the application pool was re-cycling early and kicking the sessions.
It wasn't
However, when we tried to relpicate, we could never relicate it when we went directly to one of the web servers, and sometimes replicate it when we went via the load balancer.
The load balancer was therefore the problem. The load balancer used sticky concurrent sessions, so we shouldn't experience problems. However, sticky concurrency comes with a timeout of 5 minutes. This meant that the following would happen:
- User would come in via load balancer and be assigned to web server 1
- User would leave browser open and idle for over 5 minutes, but under 20 minutes
- The sticky concurrency would timeout
- If web server 1 were busy, the user would be pushed onto web server 2 loosing the inProc session on web server 1
So, if you are using InProc sessions in a load balanced environment with sticky concurrent sessions and experience random timeouts, there are a couple of things that could be changed.
- Stop using InProc sessions and use a state server or Sql server to hold sessions in one place
- Increase the sticky concurrent timeout to a value equal to or above the session timeout
Cheers
Rich