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.

我們一直在間歇性地處理服務問題並且已經改變了一些東西,例如machine.config中的machineKey。

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.

我的實際問題是監控州服務。我們在托管服務的服務器上運行了所有4個可用性能計數器,但我們還沒有看到單個會話超時。我們還看到活躍會話的數量在一段時間內緩慢上升,但從未變得更少。

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.

編輯:我們放棄了狀態服務,並使用了SQL服務器會話。

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.

為了回答下面的問題,似乎會​​話一直持續到服務崩潰為止,並且任何oen線程都鏈接到狀態服務器是非常值得懷疑的。這是一個相當基本的網絡應用程序在一天結束時。

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.

MS似乎幾乎沒有關於這個主題的文檔。

4 个解决方案

#1


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?

您是否確保在機器和Web配置文件中都有適當的設置?

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

假設默認設置,狀態服務應在20分鍾不活動后丟棄每個會話。

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.

您的非活動會話在什么時候下降?我認為它們不會呈指數級增長,除非您重新啟動服務以清除它們,否則必須在某些時候刪除它們。

#2


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.

你有什么東西可能會在你不知道的情況下擊中會話並保持活力嗎?是否有某個線程正在產生一些正在做背景的工作並堅持你的會話?據我所知,超時是在web配置文件中設置的,它不是那里的魔法。

#3


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

我認為你可以探索其他產品,以達到最佳效果。一個免費選項是Velocity,但它仍未發布。另一個全面但經過驗證的產品將是(實際上非​​常昂貴)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,如果你有足夠數量的點擊進入,你的服務器很快就會死掉(我相信你已經有一些點擊讓你做網絡農場或你只是為了冗余而這樣做)

#4


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.

如果您遇到狀態服務器問題,那么Web應用程序中可能存在錯誤。查爾斯上面的評論似乎是開始檢查的好地方,但某處存在生命周期問題。

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).

返回代碼並檢查您的假設。拿一台新電腦,訪問你的網站(創建一個會話),讓它坐一個小時。如果你的會話還活着,那就錯了。創建一個新的Web應用程序,只有一個頁面報告當前會話的年齡並嘗試相同的事情。您應該發現一小時后(默認為20分鍾)會話不再有效。現在你有一個按預期運行的系統和一個不使用相同會話服務器的系統,所以你可以將問題排除在外,現在開始通過代碼/配置,看看你可以保持活着的位置(或防止超時)。

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:

順便說一下,這是一個“有效”的會話配置。如果你沒有看到這樣的東西,你可能會發現你的問題:

<sessionState 
   mode="StateServer" 
   stateConnectionString="tcpip=10.1.1.1:55455" 
   cookieless="false" 
   timeout="20" />

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

另外,請確保您沒有使用machine.config覆蓋web.config以使其超時更長。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/02/12/7252491503cf3d0dd0b9c5536c94c764.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com