InProc session usage in server farms
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.
精彩评论