Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET session state and multiple worker processes

I need to understand something about ASP.NET session state, as it applies to IIS 7 and ASP.net 3.5.

If an application is configured to use in-process session state, will that work OK if there are multiple worker processes? In other words, do worker processes share session state?

The default configuration for IIS 7 is to use in-process session state and to allocate a maximum of 10 worker processes. It would seem likely then, that this default configuration should work. I'm dealing with a company that has produced an ASP.NET MVC web app that is having some problems, they're blaming the server environment. The claim is that because I'm using the default settings of 10 worker processes, that is breaking their session state. I need to know whether this is in fact an accurate claim. I've never known an ASP.NET app to not work with the default configuration, so I'm a bit confused and need to have this clarified.

like image 977
Tim Long Avatar asked Jan 27 '10 14:01

Tim Long


People also ask

Which session mode is the most secure?

Secure Session-State Configuration The session-state feature is enabled by default. While the default configuration settings are set to the most secure values, you should disable session state if it is not required for your application.

Which is the best session state mode?

The InProc Session State Mode stores session data in a memory object in the application worker process (aspnet_wp.exe) in the application domain. It is usually the fastest, but more session data means more memory is used on the web server, and that can affect performance.

What are the different types of session mode available?

Each option is identified as a session-state mode type. There are four mode types or just modes. In-Process mode, State Server mode, SQL Server mode, Custom mode and Off mode. These are modes.

What is InProc mode in session?

InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is stored as life objects in the AppDomain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on IIS) or the AppDomain restarts.


2 Answers

Having multiple worker processes and using InProc does not seem to be compatible.

See this:

If you enable Web-garden mode by setting the webGarden attribute to true in the processModel element of the application's Web.config file, do not use InProc session state mode. If you do, data loss can occur if different requests for the same session are served by different worker processes.

like image 144
Michael Krauklis Avatar answered Sep 23 '22 02:09

Michael Krauklis


More than one worker process is a "web garden." In-process session state will not work correctly. You'll need to use either a single worker process for your web app, or use a session state server, or SQL Server for session state.

like image 28
TheObjectGuy Avatar answered Sep 25 '22 02:09

TheObjectGuy