Fix 100% CPU usage by w3wp.exe (IIS 7)

One of my windows servers was using 100% CPU very often. Every time it encountered that usage level, I had to restart the server. That fixed the issue at that time but then It would come back later. So after looking deeper into the problem for a while, I finally figured out what causing it and how to fix it.

It's the w3wp.exe process which is the IIS worker process that eating all the CPU for some reasons. Then the workaround is to increase the number of worker per app in IIS Manager:

1.Go to Start > Control Panel > Administrative Tools > Internet Information Services (IIS) Manager.

2. Expand the view to [Server Name] > Application Pools.

3. Right click on your app pool and select Advanced Settings....

4. Under Process Model section, set the Maximum Worker Processes... to 2 or higher.

5. Click on OK to save the settings.

6. Restart the App Pool by right clicking and select Stop then Start.

7. Make sure the session stays in all processes:

- Go to Start > Control Panel > Administrative Tools > Services.

- Right click on ASP.NET State Service and select properties. Set the startup type to automatic. Click on OK then start this service.

- Open your Web.config with notepad.

- Add the following under <system.web> and save the file:
<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" cookieless="false" timeout="20" />

Reference:
[0] http://clients.tcadmin.com/knowledgebase.php?action=displayarticle&id=11
[1] https://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.85).aspx

Comments