'in-proc' Session State mode on a multiple server setup?

一世执手 提交于 2019-12-06 01:31:30
R.C

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:

Imagine that the web request is routed to farm machine A and the code invoked by the request relies on some parameters stored in the session. If the same user is then routed to machine B in the next web request which also relies on the session state then the results will be unpredictable.

There is something called StickySessions which can tackle above scenario. But is it really good ?

This feature means that if a client returns for a second request then the load balancer will redirect that traffic to the same web server. It is also called client affinity. This can be important for web servers that store session state locally so that when the same visitor comes back then we don’t want the state relevant to that user to be unavailable because the request was routed to a different web server.

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/

You can use AppFabric Session state to mange distributed sessions

http://msdn.microsoft.com/en-us/library/hh361709(v=azure.10).aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!