CPU rate limits in Windows Server 2008 R2 and Windows 7
Updated: February 2, 2010
Applies To: Windows 7, Windows Server 2008 R2
This article documents support for limiting the CPU usage of processes running under a user account. CPU rate limits can be used to constrain CPU usage on a per account basis within the system. There are some limitations with the implementation of CPU rate limits which will be explained below in the Remarks section, so it is advisable to thoroughly test your application with the required setting before deployment.
There are two ways of limiting CPU usage in a system Hard and Soft; in hard quota management the system will ensure that processes only utilizes the amount of CPU specified and in soft quota management the system will provide hints but makes no guarantees on enforcing CPU utilization limits.
Hard quota management for processes was first implemented in Windows Vista® and improved in Windows® 7and Windows Server® 2008 R2. CPU limits are implemented on a per-account basis by specifying the security descriptor of the user account (SID) and the maximum percent of CPU usage in the registry.
The quota system is accessed through the registry under the key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Quota System. CPU rate limit can be set on an account by creating a new key with the security ID (SID) of the account and under that key creating a CpuRateLimit value. Alternatively, the value may be specified directly underneath the Quota System key, whereby it is the default rate limit applied to the remaining processes in the system.
The CpuRateLimit value contains the maximum percent of CPU resource all the processes running under that SID can use within a time window. The time window on Windows 7and Windows Server 2008 R2 is 500 milliseconds and 1 second on Windows Vista. CpuRateLimit is the maximum percent of CPU usage in a time interval so it can only take values between 0 and 100. Note the limits are enforced against the available CPU bandwidth, which is based on the number of processors present in the system.
If you want to limit processes running under the account with SID S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415 to use only 10% of the CPU bandwidth, you would do the following;
Open an administrator command prompt.
reg add HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Quota System\S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415.
Open the Registry Editor and locate the sub key you created in the previous step.
Under this key, create a new REG_DWORD value CpuRateLimit and set its value to 10.
This will limit all the processes running under that account SID to use only 10% of the CPU.
There are a couple of caveats to using and understanding CPU rate limits:
Since these are hard quotas, if the processes within a SID hit their limits within the enforcement time interval then that those process will suspended until the start of the next enforcement window.
Any work that a process in one SID causes another process in a different SID to undertake is not charged back to the original process.