Search code examples
asp.netconfigurationiis-7long-running-processes

Considerations for ASP.NET application with long running synchronous requests


Under windows server 2008 64bit, IIS 7.0 and .NET 4.0 if an ASP.NET application (using ASP.NET thread pool, synchronous request processing) is long running (> 30 minutes). Web application has no page and main purpose is reading huge files ( > 1 GB) in chunks (~5 MB) and transfer them to the clients. Code:

while (reading)
{
    Response.OutputStream.Write(buffer, 0, buffer.Length);
    Response.Flush();
}

Single producer - single consumer pattern implemented so for each request there are two threads. I don't use task library here but please let me know if it has advantage over traditional thread creation in this scenario. HTTP Handler (.ashx) is used instead of a (.aspx) page. Under stress test CPU utilization is not a problem but with a single worker process, after 210 concurrent clients, new connections encounter time-out. This is solved by web gardening since I don't use session state. I'm not sure if there's any big issue I've missed but please let me know what other considerations should be taken in your opinion ?

for example maybe IIS closes long running TCP connections due to a "connection timeout" since normal ASP.NET pages are processed in less than 5 minutes, so I should increase the value.

I appreciate your Ideas.


Solution

  • Use Web-Gardening for more stability of your application.

    Turn-off caching since you don't have aspx pages

    It's hard to advise more without performance analysis. You the VS built-in and find the bottlenecks.