Optimizing Windows IIS Server

Most IIS instances are fine with default settings. However, it’s often beneficial to configure some recommended settings on multi-core machines so that Web Services would run optimally:

  1. Set CPU Limit to prevent server from maxing out CPU when there are ‘runaway’ processes. Here’s an example config on a 16-core server:
  2. Specify processor affinity to exclude IIS utilization of CPU-0. As the networking stack is highly dependent on this default core, reserving it for OS and packets processing would be improve resource handling and overall server processing speed. On NUMA enabled servers, this would apply be required as an extra step to enable processor affinity:
    # IIS 10.0+ would require disabling IIS Thread Pool Ideal CPU Optimization on a Non-Uniform Memory Access (NUMA) server
    set-itemproperty -Path $regKeyCpuOptimization -Name $keyName -Value $disable
  3. Disable Overlapped Recycle should be set to True – as opposed to the default value of False. Recycling “Specifies whether the WWW Service should start another worker process to replace the existing worker process while that process is shutting down. The value of this property should be set to true if the worker process loads any application code that does not support multiple worker processes. (source: https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/recycling/)
  4. Cap Virtual Memory Limit to about 85% of server’s RAM capacity would ensure that  there is enough reserve for the OS and antivirus programs.
    $memoryKb=(gwmi -Class win32_operatingsystem).TotalVisibleMemorySize
    write-host "$memoryPercent`% of RAM on $env:computername is $($memoryKb*$memoryPercent/100)"
Posted on Categories Codes

Leave a Reply

Your email address will not be published. Required fields are marked *