简体   繁体   中英

SQL Server Session State, web farm, and counting the sessions

I have 2 load balanced web servers. My application is using the SQL Server Session State database on SQL Server 2008.

The 2 web servers are identical in terms of IIS configuration, and if I understand correctly, the two web apps on the two servers will be mapped to the same app id in the ASPStateTempApplications table since they have the same IIS configuration. So, counting the number of sessions associated with this app Id (from the ASPStateTempSessions tabel) will result in the total count of sessions on the two web servers together.

My questions is: Is there a way to know how many sessions are active on each server individually?

I have the problem that when I take one server out of the load balance, I want to know if there are still any active sessions on the server or not before recycling it.

Another scenario, if I have to recycle the IIS on one of the servers because another web app on the same server is crashing, I would like to know how many sessions will be affected when I do so.

Thanks.

Basically, they all may and actually SHOULD be active on both ) Because in this mode sessions are not bound to the web-servers at all.

You can stick each user to a single server with load-balancing techniques on your gateway and if so - better to use InProc mode with all its benefits )

Since the session data is stored in SQL Server, you shouldn't have to worry about how many sessions are active. Once the server is shutdown (or IIS is recycled, depending on the configuration), the load balancer will automatically send any new requests to the active IIS server. With the session data stored in SQL, the active server can retrieve the session data and the user will be unaware that any server switching has occured.

Ideally, you should test this procedure periodically to make sure everything is configured correctly. Also, you should follow this procedure when installing patches to the servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM