SQL Server Session Status, Web Farm, and IIS Configuration

So, I configured the state of the SQL Server session using SQL Server 2008 and the temp database, and today I decided to examine the data in the tables to find this in the ASPStateTempApplications table:

AppId AppName
538231025 / lm / w3svc / 1 / root
611758131 / lm / w3svc / 3 / root
802488340 / lm / w3svc / 4 / root
-940085065 / lm / w3svc / 4 / root / webapp
685293685 / lm / w3svc / 5 / root
1210055478 / lm / w3svc / 5 / root / webapp

We have 2 load balanced web servers.

When I look at the web application identifiers of both servers, I see that web1 has app1 with id 4, and web2 has app1 with id 5. The same thing happens with the other application. web1 has app2 with id of 1 and web2 has app2 with id of 3.

My common sense tells me that web servers do not use sessions, as the session identifier uses the application. I'm right? If so, why is this minor detail not so obvious in the documentation? Should I match identifiers on both web servers?

+6
sql-server iis-7
source share
1 answer

AppId is used during the creation of SessionId to avoid collisions from one application to another. It is created by computing the hash of the IIS application path.

In your environment, a stream might be something like this:

  • Server A creates a session identifier, sets it to a cookie, and stores some data in the corresponding session (line in ASPStateTempSessions). The session identifier column is created by concatenating the session identifier using the AppID.
  • Server B receives a request with an existing session identifier and uses it to search for related session data from the ASPStateTempSessions table. If the application ID is different, the generated key will also be different.

The net effect of having multiple servers with different applications that use the same sessions is that identifiers created by one server will not interfere with data from another server, and machines with different applications will not see each other.

+6
source share

All Articles