My Team is using 'in-proc' Session State mode on a multiple server setup. This does not seem right to me obviously because the session state is going to be unique on each server and will not be shared.
We have approached this problem by giving the same Machine Key on both servers (in the application's config file.) But I have a feeling this would not actually help...
Any light on this is appreciated.
Thanks!
When using
InProc
session state, the session will be stored locally on the server which served the request and therefore using the same Machine Key on both servers won't serve the purpose.This option is not fit for use in a web farm environment. One farm machine stores the session state but not the other. Subsequent web requests from the same user may not read the correct session state.
Consider a very common scenario:
There is something called StickySessions which can tackle above scenario. But is it really good ?
This definitely beats the very purpose of load balancing in a web farm.We should avoid this solution so that the load balancer can pick the “right” machine in a farm based on the current load.
Read here for a complete understanding: http://dotnetcodr.com/2013/07/01/web-farms-in-net-and-iis-part-5-session-state-management/