My ASP.NET application is a download application (no pages) which reads huge binary files (1-2 GB -> over 1 hours download time with resume support) from local network and stream them to web clients (each request -> one large binary response, so there’s no text/html response at all). I use a HTTP Handler (.ashx) instead of a (.aspx) page for processing requests. Using a shared buffer and producer-consumer pattern main thread (from ASP.NET thread pool) creates another thread and together they accomplish the job. At the end both threads exit (get back to pool).
So I have long-running request using threads from thread pool which is not recommended generally but I don’t have any page in my application, is it still a bottleneck using threads from ASP.NET thread pool ?
Environment: server 2008 64bit, IIS 7.0 and .NET 4.0
What considerations should be taken for this scenario ?
Any comment is appreciated.
As I explained here, just use
IHttpAsyncHandlerimplementation in ASHX to launch a custom thread and finish with processing inside asp.net thread (thus returning it to the pool). Using this you can initiate thousands of downoads per second without running out of asp.net thread pool threads. (How and if you wish to serve that many requests is another topic of discussion)Edit: just don’t forget to call
asyncRequestState.CompleteRequest()at the end of your thread, otherwise asp.net won’t know that you are done serving the request.