Prizes & Awards
My Profile
Active Members
TodayLast 7 Days
more...
|
New Feature: Community Sites:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
|
ASP.Net State Server Management in Webfarm and WebGarden
|
ASP.NET – SESSION STATE MANAGEMENT
The modes of session state are basically classified into In-process and Out-process. • In-process – InProc • Out-process – StateServer / SQL Server • None
Where it stores
• InProc - Session kept as live objects in web server (aspnet_wp.exe). • StateServer - Session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine. • SQLServer - Session serialized and stored in SQL server
Performance
• InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance. • StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing lots of objects. • SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.
How frequent the session will lose • InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. • StateServer - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. • SQLServer - Similar to StateServer. Moreover, session state data can survive a SQL server restart, and you can also take advantage of SQL server failover cluster by running the InstallPersistSqlState.sql and UninstallPersistSqlState.sql scripts. More on Microsoft KB Article ID: 311209 [When you use the original SQL Server mode session state management script files (InstallSqlState.sql and UninstallSqlState.sql), the ASPStateTempApplications and the ASPStateTempSessions tables are created in the tempdb database to store the session data. However, the session state data is lost if you restart the computer that is running SQL Server. The persisting versions of the scripts (InstallPersistSqlState.sql and UninstallPersistSqlState.sql) resolve this problem by creating these tables in the ASPState database instead. Therefore, the session data is retained after you restart the computer that is running SQL Server.]
InProc It won't work in web garden mode, because in that mode multiple aspnet_wp.exe will be running on the same machine. Switch to StateServer or SQLServer when using web garden. Also Session_End event is supported only in InProc mode.
StateServer • In a web farm, make sure you have the same in all your web servers. • Also, make sure your objects are serializable. • For session state to be maintained across different web servers in the web farm, the Application Path of the website (For example \LM\W3SVC\2) in the IIS Metabase should be identical in all the web servers in the web farm.
SQLServer • If you specify integrated security in the connection string (e.g. "trusted_connection=true", or "integrated security=sspi"), it won't work if you also turn on impersonation in asp.net. Unfortunately, this bug isn't reported in KB yet. (There is a QFE fix for it.) • Also, make sure your objects are serializable. • For session state to be maintained across different web servers in the web farm, the Application Path of the website (For example \LM\W3SVC\2) in the IIS Metabase should be identical in all the web servers in the web farm.
WebGarden / Webfarm
WebGarden – A single machine has multiple aspnet worker processes running simultaneously. To achieve, machine should have multiple CPU’s and scheduling job is done by windows. To setup, Open machine.config -> processmodel section • Set WebGarden attribute to True • cpuMask attribute is used to indicate which CPU can run ASP worker processes
Webfarm - where the worker processes are running on more than one machine connected together. To setup, Open machine.config -> machinekey section • The validation key and decryption key are default set to autogenerate. This will be change to single key across all the machines in the web farm.
Where to use: Webfarm is also simply used to mean a business that performs website hosting on multiple servers.
WebGarden="false" 1. This would mean that the aspnet worker process is utilizing only one CPU. 2. The %Processor Time counter would give a more optimistic read of the situation than is the case, because it will average out the time over 2 processors when only one is being utilized. WebGarden ="true" 1. This implies we need to use out-of-process technique for doing session state management, like the asp.net state service which it has about 15% slower.
So, using a dual-processor machine is of benefit to asp.net only if WebGarden is set to "true" and an out-of-process technique for session management is being used.
Note: When using State server or SQL Server Session state mode, session state may be lost when you run an ASP.NET web application in a load balanced Webfarm. Workaround is on microsoft KB article ID: 325056.
|
Responses
|
| Author: Mahesh Raj 07 Jun 2008 | Member Level: Gold Points : 1 | This is very good information,Continue posting such useful articles.
| | Author: John Fernandez 08 Jun 2008 | Member Level: Gold Points : 1 | Very well written Article.Thanks for sharing this information.
|
|