Sunday, September 6, 2015

.NET optimization service at very high CPU utilization

On Server 2012 R2, after running Windows Update to install important updates, the CPU utilization of the server could get pegged at 100% due to .NET optimization service (Ngen.exe).

As the name suggests, all installed .NET frameworks are being optimized via re-compiling, which leads to a prolonged period of 100% CPU usage.

Run the following if you want to get this optimization process over with at your command. Run it and come back after a while (10~20 min). When it is done, the server should behave normally.

 Get-ChildItem $env:SystemRoot\\NGen.exe -recurse | ForEach-Object { & $_ executeQueuedItems }

Basically, the command above lets us to run "Ngen.exe  executeQueuedItems" per each .NET Framework versions manually at the time of our choosing, rather than letting the server finish when it can later, which may cause unexpected slowness in performance.

After optimization is done for each .NET Framework version, when running the command again, you will see confirmation message like below.

No comments: