ASP.Net State Service的問題

[英]Problems with ASP.Net State Service

We have an ASP.Net 2.0 web application running in a web farm which is using the ASP.Net State service to store sessions.

我們有一個在Web場中運行的ASP.Net 2.0 Web應用程序,它使用ASP.Net State服務來存儲會話。

We have been having problmes with the service intermittently and have changed a few things such as the machineKey in the machine.config.


My actual question is around the monitoring of the state service service. We have all 4 available performance counters running on the server that hosts the service and as yet we have not seen a single session time out. We have also seen the number of active sessions slowly rise over a period of time, but never become less.


Does the state service recognise when sessions time out? Is there something we should be doing manually?


Edit: We have given up on the state service and gone with SQL server sessions.


To answer the questions below, it seems that sessions go up forever until the service falls over and it is very doubtful that any oen threads are linked to the state server. This is a fairly basic web app at the end of the day.


It seems from the reading I am doing that anumber of other people have experienced similar things, but there seems to be a general lack of common sense and knowledge in any responses flying about.


MS seem to have almost no documentation on this topic.


4 个解决方案


In ASP.Net session time outs can be configured in web.config and machine.config. The default time out assuming nothing has changed will be 20 mins. The machine.config file can be set to not allow overriding, which means that any changes specified in web.config files will not override these settings.

在ASP.Net會話中,可以在web.config和machine.config中配置超時。假設沒有任何改變的默認超時時間為20分鍾。 machine.config文件可以設置為不允許覆蓋,這意味着web.config文件中指定的任何更改都不會覆蓋這些設置。

Have you ensured that the appropriate settings are in place in both machine and web config files?


The state service should drop each session after 20 mins of inactivity assuming the default settings.


At what point are your inactive sessions dropped? I assume they are not exponentially increasing, unless your are restarting the service in order to clear them they must be being dropped at some point.



Do you have something that might be hitting the session and keeping it alive without you knowing? Is there are thread being spawned somehwere that is doing work inteh background and holding on to your session? As far as my expeireince goes the timeout is set int he web config file and it just doesn't it's magic from there.



In my experience we've found out that native state server or even using SQL Server for sessions is a very scary scenario as both have issues.

根據我的經驗,我們發現原生狀態服務器甚至使用SQL Server進行會話是一個非常可怕的情況,因為兩者都有問題。

I think you can explore other products for this to achive the absolute best. A free option would be Velocity but it is still not released.
And another comprehensive but proven product will be (Very expensive actually) NCache


Take a look and see which looks best for you.


About SQL Server, you server will die very soon if you have enough number of hits coming in (I belive you have some hits already which yielded you to do Web Farm or you do it just for the sake of redundancy)

關於SQL Server,如果你有足夠數量的點擊進入,你的服務器很快就會死掉(我相信你已經有一些點擊讓你做網絡農場或你只是為了冗余而這樣做)


I am sure this will get modded down, but I have to say it.


If you are having issues with the state server, then there is likely an error somewhere in your web application. Charles' comment above seems like good places to start checking, but somewhere there is a life cycle issue.


Go back over the code and check your assumptions. Take a new computer, visit your website (create a session) and let it sit for an hour. If your session is still alive, then something is wrong. Create a new web application that just has a single page reporting the the age of the current session and try the same thing. You should find that after an hour (default is 20 minutes) the session is no longer valid. Now you have a system that is working as expect and one that is not, both using the same session server, so you can rule that out as the problem, now start going through code/configuration and see where you could be keeping it alive (or preventing the time-out).


Here, by the way, is a 'valid' session config. If you don't have your looking something like this, you have likely found your issue:


   timeout="20" />

Also make sure you are not overriding your web.config with your machine.config to have a longer timeout.




粤ICP备14056181号  © 2014-2021