When Session Variables Go Bad

Down on the Web Farm

Our final issue with Session variables arises when your application get scaled out across a number of servers. Typically, when you have multiple servers processing the requests for a single site (a web farm), there is some load balancing hardware or software that determines the lucky server that gets the next request. The most common algorithm used by the load balancer is a simple round robin. You think that you had problems with thread affinity! All of the Session variables are sitting on the server which handled the initial assignment. So if it should happen that the next page request is processed by a different server, all of the session information is lost. Now to be fair, there is software available that will 'pin' all of the page requests from a single session to one server. In fact Microsoft's Load Balancing Service will do that for you. However you are reducing the overall performance of the application. You could easily get the situation where one server is processing four or five sessions while there are other servers sitting idle.

You might also like...


About the author

Bruce Johnson Canada

I am the owner of a small application development consulting company that specialized in the design and implementation of Internet-based applications. While there are others who can make a web ...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth