asp.netasp.net-mvciishttp-errortweak

Internal server error 500 when tweaking web.config using maxWorkerThreads


I would like to improve performance for an ASP.NET Web Application on IIS. Sometimes when many users connect to it, it gets too slow. This app uses the default InProc mode as session state. Before trying web garden or web farm I have decided to try other alternatives such as tuning below parameters in web.config file under system.web section:

<system.web>  
    <processModel maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/>

    <httpRuntime minFreeThreads="704" minLocalRequestFreeThreads="608"/>
</system.web>

After setting these parameters I cannot access to ASP.NET application, I am getting error 500 internal server error.

If I remove above settings, application works.

Server is a virtual machine and it has an Intel® Xeon® Processor E5 v3 with 12 virtual processors.

Any ideas?


Solution

  • Finally I have solved it.

    In order to below line to work:

    <processModel maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/>
    

    ...a modification is needed in machine.config file in:

    systemroot\Windows\Microsoft.NET\Framework\VersionNumber\Config
    systemroot\Windows\Microsoft.NET\Framework64\VersionNumber\Config
    

    Where VersionNumber corresponds to the .NET Framework version you are using, in my case was v4.0.30319

    You must change allowDefinition from MachineOnly to MachineToApplication for processModel section in Machine.config file:

    <section name="processModel" type="System.Web.Configuration.ProcessModelSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineToApplication" allowLocation="false" />
    

    Finally, the culprit because below line was not working:

    <httpRuntime minFreeThreads="704" minLocalRequestFreeThreads="608"/>
    

    ...was because this line was being duplicated a few lines below in web.config file as:

    <httpRuntime targetFramework="4.5" maxRequestLength="102400" executionTimeout="3600" maxQueryStringLength="8192" />
    

    so I have combined them into below one:

    <httpRuntime targetFramework="4.5" minFreeThreads="704" minLocalRequestFreeThreads="608" maxRequestLength="102400" executionTimeout="3600" maxQueryStringLength="8192" />
    

    Links of interest: