简体   繁体   中英

Session_End event behind load balancer

I'm creating web application behind load balancer. To this moment I configured it to store session in database but I'm not sure how should I handle session expiration. The problem is not sessions are not removed from database but Session_End event because I have to call some web service method in it.

Assuming Session_End is called when expires the thing I'm afraid of is situation when session is created on one server but finished on another. In this case I'm afraid Session_End on first server will be executed prematurely and I will call web service too early. What would you suggest in this situation?

Edit:

I remember some time ago reading about Sql Agent reacting to session end event and then performing custom code. Can anybody confirm that this solution is possible?

The session end event is not supported unless you are using in-process session state. You could look at ScaleOut Software StateServer. I am considering this for my own environment. It implements a distributed session state and support a session end event.

Edit to add more info:

Their web site explains it better that I can ( details page ), but here is a quick summary. ScaleOut (or similar gadgets) use a distributed cache to manage session state. This means that a process on each of your servers holds session data. The processes communicate between servers, so that all data is shared among all the servers - whichever server happens to be processing a user request, the same session data is available. If one of your servers fail, all session data is preserved, since it is distributed across all servers. In contrast, asp.net provides in-process session state which works only on a single server, a session state server which holds session data in a separate single server (a single point of failure), or sql server session state, which is quite robust, but hurts performance.

Isn't this exactly why you are storing session information within a database?

This solves the problem of "which server is the session on."

As stated below Session_End is only called for inProc session, which you won't be using.

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