2011-05-14 19 views
0

我正在嘗試使用IIS來託管事件驅動的Web應用程序。比方說,我想用它來聊天類應用程序。ASP.Net並通過開放連接監聽事件 - 是否有可能提高併發執行的線程數量?

而不是每隔一秒輪詢一次(延遲)我想留下一個打開的連接到我的應用程序,該應用程序返回一旦有數據可用。

問題是我無法獲得超過10個併發線程執行。

我將MaxThreads設置爲5000/5000,MaxConcurrentRequestsPerCpu爲5000,默認情況下QueueLimit爲5000,MaxConcurrentThreadsPerCPU爲0(無限制)。

唯一的問題是,默認情況下,DefaultConnectionLimit似乎是12,我似乎無法改變它在我的web.config中。我設法在global.asax Application_Start中設置它,但我不知道在這個時候設置它是否太遲。它在文檔中說它不影響已經初始化的ServicePoints。

<system.net> 
    <connectionManagement> 
    <add address="*" maxconnection="100" /> 
    </connectionManagement> 
</system.net> 

上面是我在我的web.config(涉及DefaultConnectionLimit)。

5/14/2011 3:34:45 PM with timediff 0   : Entered method with threadId: 6, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:45 PM with timediff 0   : Entered method with threadId: 5, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4998 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:46 PM with timediff 0.5  : Entered method with threadId: 7, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4997 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:47 PM with timediff 1.5  : Entered method with threadId: 8, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4996 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:48 PM with timediff 2.5  : Entered method with threadId: 9, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4995 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:49 PM with timediff 3.5  : Entered method with threadId: 10, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4994 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:50 PM with timediff 4.5  : Entered method with threadId: 12, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4993 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:51 PM with timediff 5.5  : Entered method with threadId: 13, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4992 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:52 PM with timediff 6.5  : Entered method with threadId: 14, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4991 and DefaultConnectionLimit is 1500 
5/14/2011 3:34:52 PM with timediff 7   : Entered method with threadId: 15, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 5000, MaxConcurrentThreadsPerCPU is 0, MinThreads is 1, AvailableThreads is 4990 and DefaultConnectionLimit is 1500 
5/14/2011 3:36:45 PM with timediff 120  :  Exiting method with threadId: 6 
5/14/2011 3:36:45 PM with timediff 120  :  Exiting method with threadId: 5 
5/14/2011 3:36:46 PM with timediff 120.5  :  Exiting method with threadId: 7 
5/14/2011 3:36:47 PM with timediff 121.5  :  Exiting method with threadId: 8 
5/14/2011 3:36:48 PM with timediff 122.5  :  Exiting method with threadId: 9 
5/14/2011 3:36:49 PM with timediff 123.5  :  Exiting method with threadId: 10 

以上是我生產的用於測試線程併發性的日誌文件的摘錄。它只是一個MVC動作方法,其中有120秒的睡眠時間。 Timediff是從第一個請求到當前正在記錄的請求的差異。

正如您所看到的,AvailableThreads下降到4990,然後等待其他線程退出,然後再繼續。請求之間的延遲似乎是小提琴故障(我用來加載測試)。

我也試過BadBoy發出相同的請求,它也受到10線程限制。

這是因爲連接來自同一個客戶端嗎?是否有其他限制我錯過了?對於不同的主機進行負載測試顯然是很困難的。

回答

1

如果你在Windows 7下測試你的應用程序。它有10個併發連接限制。此外,您可能會發現(IISTuner)有用。

+0

@Zuum謝謝!該死的,那條信息不容易搜索。應該在服務器版上試用。你有沒有提到這一點的資源,還提到了Windows Server 2008/R2的限制? – Max 2011-06-03 10:54:56

+0

我不知道Server 2008.是否有限制。請觀看此視頻:http://www.youtube.com/watch?v = flj-919bKMU – Zuuum 2011-06-06 13:40:18

相關問題