26

Environment: Windows Server 2008 Enterprise, IIS 7.0, ASP.NET 2.0 (CLR), .NET 4.0

I have an ASP.NET application with no page and no session(HttpHandler). It a streaming server. I use two threads for processing each request so if there are 100 connected clients, then 200 threads are used. This is a dedicated server and there's no more application on the server.

The problem is after 200 clients are connected (under stress testing) application refuses new clients, but if I increase the worker threads of application pool (create a web garden) then I can have 200 new happy clients per w3wp process.

I feel .NET thread pool limit reaches at that point and need to increase it.

Thanks

Xaqron
  • 29,931
  • 42
  • 140
  • 205
  • 1
    It sounds like you're using your threadpool for long-running tasks and run into a scaling issue. Are your threads working at maximum speed, or are they blocking? Have you researched an asynchronous implementation instead? – sisve Dec 31 '10 at 18:40
  • 2
    You are right they are long-runnig threads by design. As I told this is the only business of the application/server. Threads are fully utilized and never go sleep or idle. This is not a normal `ASP.NET` application where Async threads do something in background., so nothing can do better for design since this is the nature of application. – Xaqron Dec 31 '10 at 20:08

1 Answers1

27

Look at the applicationPool element of your aspnet.config:

<configuration>
  <system.web>
    <applicationPool 
        maxConcurrentRequestsPerCPU="5000"
        maxConcurrentThreadsPerCPU="0" 
        requestQueueLimit="5000" />
  </system.web>
</configuration>

An example location is:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

You may also want to look at processModel (in your machine.config).

demoncodemonkey
  • 11,730
  • 10
  • 61
  • 103
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • I use Visual Studio 2010, web.config schema doesn't support such tag, also it's on MSDN website. Any idea ? – Xaqron Dec 31 '10 at 20:15
  • @Xaqron - What version of .NET are you targeting? This is a .NET 4.0 feature. It _is_ on MSDN, as I have linked. `processModel` has always been there. – Oded Dec 31 '10 at 20:50
  • I use .NET 4.0, but it's not there in web.config anyway `ProcessModel` solved my problem for now since no other application is on server but I'll be glad to know why my web.config schema doesn't support `applicationPool`. – Xaqron Jan 01 '11 at 00:48
  • 6
    This configuration must be added to aspnet.config, not web.config. – Spongeboy Aug 16 '12 at 12:24
  • 1
    @Spongeboy - You could have simply edited the post to correct it. – Oded Aug 16 '12 at 12:31
  • 1
    Thanks for saving my days, maybe weeks! – Roni Tovi May 20 '19 at 09:35