Use specific processors in IIS (Processor Affinity)

IIS websites use all the available CPU power by default. You can play around the application pool settings if you want to assign specific processors to specific websites.



The settings related to CPU usage are in the CPU section of the Advanced settings:

medium?v=1.jpg



For descriptions of all CPU related settings, visit this Microsoft document: CPU Settings for an Application Pool



Here are a few example scenarios to explain this topic:



Choose 1 core (first core) out of 2



Let’s say you want to use only one core out of two to run your website. Set the following parameters:

Processor Affinity Enabled = TrueProcessor Affinity Mask = 1

medium?v=1.png



This parameter uses binary representation. Processor Affinity Mask is a 32-bit value. Each bit represents a processor (core). A bit set to 1 means that processor should run the website.



Processor Affinity Mask in the application pool settings is an integer value. In order to find out what number it should be, you should start from binary representation. Then convert it to an integer.



Choosing the first processor means setting the first bit to 1:

00000000000000001



Since the binary value above equals to integer value 1, there is no complexity here.



Choose 4 cores (first 4 cores) out of 8



If you want to use only the first 4 cores of your CPU power out of 8 cores the binary representation would be:

00000000000001111



This binary value equals to 15 (1 + 2 + 4 + 8). You can use the Windows Calculator in Scientific mode to make this calculation.



So in this example, you should enter 15 into the Processor Affinity Mask field.



Choose the last 12 cores out of 24



Binary representation:

111111111111000000000000



This binary set is equal to 16773120 which is the number you should use as the Processor Affinity Mask.

Continue reading...
 
Top Bottom