开发者

InProc session usage in server farms

开发者 https://www.devze.com 2023-02-08 06:41 出处:网络
I\'m reading ASP.NET 4 Unleashed and I came to this sentence. \"When Session state is stored in-process, it is stored on a particular web server. In other words, you can\'t use in-process Session stat

I'm reading ASP.NET 4 Unleashed and I came to this sentence. "When Session state is stored in-process, it is stored on a particular web server. In other words, you can't use in-process Session state with a web farm."

Ooops. I'm building a web app that uses and depends on storing 开发者_如何学Pythondictionaries in the session. Now I know that there's some problem with serialization of dictionaries when using sessions but with InProc sessions, there's no serialization so I thought I'd be ok. But now I'm wondering: will I have any nasty surprise when I go to host my application?

Thanks.


First of, if your app runs on a single server (and possibly on a shared hosting), in-proc session is OK and probably the only way to go.

But, if you have more than one server (web farm) or even more than one process on the same server serving your web site (web garden) in-proc will not work unless you use sticky sessions: your load balancer will need to be configured to send requests to the same server after the session is started.

Do not worry about dictionary serialisation, session handling must be able to sort it out, be it state server or SQL Server.

Generally, however, any reliance on an in-proc session or state limited to the process boundary is considered bad design and is highly discouraged.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号