Thursday, November 20, 2008

Preserving Session State in Network Load Balancing Web Server Clusters (IIS 6.0)

Preserving Session State in Network Load Balancing Web Server Clusters (IIS 6.0)

IIS enables a Web application to maintain user session data (also called session state) across multiple requests. For example, an online ordering application might maintain the user's shopping cart as part of the user's session. IIS uses session cookies, which are text files supplied by the user's browser and stored on the user's computer for each request to keep track of which session belongs to which user.

Note

Worker processes lose session state if the worker process is recycled. The ideal configuration for storing session state with IIS 6.0 is to store user session data in a back-end database.

Ideally, Network Load Balancing always routes connections from a user who has an active session to the server where that session is stored. However, Network Load Balancing and other Layer 4 network load balancers do not use sessions or cookies to decide which Web server should handle an incoming request. For this reason, sessions can be lost between requests in a Network Load Balancing server cluster.

There are several ways to avoid losing sessions:

Design the Web site application to store session state on the client. For more information, see Preserving Session State with ASP Web Applications in Network Load Balancing and Preserving Session State with ASP.NET Web Applications in Network Load Balancing.

Store session state on a central server-side store, such as a database.

Use the client affinity feature. When client affinity is enabled, Network Load Balancing directs all TCP connections to the same cluster host. This allows session state to be maintained in host memory. You can enable client affinity in the Add/Edit Port Rules dialog box in Network Load Balancing Manager. Choose either Single or Class C affinity to ensure that only one cluster host will handle all connections that are part of the same client session. This is important if the server application running on the cluster host maintains session state (such as server cookies) between connections. For more information about Network Load Balancing affinity, see Help in the Network Load Balancing snap-in.

No comments: