Avoid IIS locks/hangs because of static contents, and improve the IIS performances !

The best asp.net programmed web site could be not VERY fast. I mean, you could be dissapointed by the performances of your website if your IIS configuration is not optimized.

The problem

You have a website with the runAllManagedModulesForAllRequests property setted to true in web.config.
What this means ? Every requests will be handled by ASP.net ! So static contents will also be handled by ASP.net !

Real Situation

You published a new page with a big flv (30Mo) and a lot of people try to watch it simultaneously (like 20/30 people) : your IIS will be locked for a good while ! If you look at the process manager, you could see the CPU around 25%, and a lot of Threads in queue !
Because ASP.net is buffering every request in the Thread Pool and it is saturating. As you know the ASP.net Thread Pool max is by default 25 (you can change it) !

Wrong Solution

You could upgrade the Thead Pool max, but it’s the wrong solution, because you will consume so much more memory and ASP.net is delivering files after buffering (you have to wait a lot of time before downloading a huge file).

Good Solution

You have to disable runAllManagedModulesForAllRequests in the sub-directory like this :

<?xml version="1.0" encoding="UTF-8"?>
<modules runAllManagedModulesForAllRequests="false"/>
<mimeMap fileExtension="." mimeType="application/octet-stream" />

This will disable ASP.net for this subapplication.
The only problem is : you have to create a sub application (not a subdirectory) to do that.

So if your directory is /content and you don’t want to update all your ResolveUrl stuff:

– rename /content as /content2
– create a sub-application named “content” with the directory C:\website\content2
– add the web.config file

It should be working. To be sure, upload a huge file (like 2Go) in content2 (the real directory) and try to download it by :
– http://website/content/hugefile.zip
– http://website/content2/hugefile.zip

The first URL /content should deliver the file instantaneously, and the the second should take a huuuge time


If all your static contents are not handled by ASP.net, you could feel a very very fast website, a general CPU decrease, even if there is a lot of people connected.


This entry was posted in Non classé. Bookmark the permalink.

Comments are closed.