I am trying to use IIS to host an event-driven web-application. Lets say I want to use it for a chat-type application.
Instead of polling once every second or so (delay) I want to leave an open connection to my application which returns once there is data available.
The problem is that I can't get more than 10 concurrent threads executing.
I've set MaxThreads to 5000/5000, MaxConcurrentRequestsPerCpu to 5000, QueueLimit is 5000 by default, MaxConcurrentThreadsPerCPU is 0 (unbounded).
The only thing is that DefaultConnectionLimit seems to be 12 by default, and I can't seem to change it in my web.config. I've managed to set it in global.asax Application_Start but I don't know if it is too late to set it at that point. It says in the documentation that it does not affect already initialized ServicePoints.
<system.net>
<connectionManagement>
<add address="*" maxconnection="100" />
</connectionManagement>
</system.net>
The above is what I have in my web.config (that concerns DefaultConnectionLimit).
5/14/2011 3:34:45 PM with timediff 0 : Entered method with threadId: 6, MaxThreads is 5000/5000, MaxConcurrentRequestsPerCPU is 开发者_JS百科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
The above is an excerpt from the log file I am producing to test thread concurrency. It is simply an MVC action method with a 120 second sleep in it. Timediff is the difference from first request to the current request being logged.
As you can see, AvailableThreads dip down to 4990, and then waits for the other threads to exit before continuing. The delay between requests seems to be Fiddlers fault (which I use to load test).
I've also tried BadBoy to issue the same requests, and it also suffers from the 10 thread limit.
Is this because the connections are from the same client? Is there some other limit I have missed? It's admittedly difficult to load-test with different hosts..
If you test your application under Windows 7. It has 10 concurrent connections limit. Additionally, you may find (IISTuner) useful.
精彩评论