Push Your Server to the Limit
Servers rarely use more than 20 percent of their available processing power. This gives systems administrators plenty of comfort, as there’s ample overhead should an application or process require that little bit extra to complete a task. But with so many CPU cycles left idle, it seems a shame not to put them to some good use.
While it may be wise to allocate one server per role, such as one server for Exchange and another for SQL, there are occasions when multiple processes or applications competing for processor and memory resources can successfully be managed on one server. Two examples of this are IIS and Terminal Services, which Windows System Resource Manager supports natively.
WSRM can guarantee that an application receives a minimum share of available processor resources when there is high overall processor utilization. It also can control processor affinity. Processes can be assigned a maximum memory working set (the total physical RAM used by a process), though this is not recommended unless it improves performance in some measurable way. Limiting a process memory working set tends to cause disk thrashing if the limit is regularly exceeded, which typically lowers overall server performance.
To control an application that is prone to memory leaks, there’s the more useful ability to terminate an application (or write to the event log) should the application exceed a predefined level of memory usage. Although it’s not possible to restart a process with WSRM, you can use Windows Server 2008’s Event Viewer to launch a custom task that will restart an application on a given event. This will return memory usage to normal, if only temporarily.
WSRM can also manage resources according to date and time, and to a limited set of hardware conditions such as addition of processors or memory and changes in the availability of cluster nodes and resource groups. By grouping processes according to user or group, you can use WSRM to give higher priority to important users, which can be useful on terminal servers or to ensure access for administrators.
Installing Windows System Resource Manager
WSRM is a feature of Windows Server 2008 that’s installed using Server Manager. Log on as Administrator and open Server Manager from the Start menu:
- Click Features in Server Manager’s left pane and then Add Features in the main window.
- In the Select Features dialog, scroll to the bottom of the list and check Windows System Resource Manager. You’ll be prompted to add the Windows Internal Database as an additional feature. Click Add Required Features to continue.
- Click Next in the Select Features dialog and then Install.
- Once the installation has completed, click Close in the Install Results dialog.
Testing Windows Server Resource Manager
To test different WSRM configurations, you might want to consider creating artificial scenarios in which applications compete for processor or memory resources. There are plenty of resource-hogging applications out there, but getting them to overload your system on demand isn’t easy.
Prime95 is an application that’s used by PC enthusiasts to stress-test systems that have been overclocked. Prime95 was developed to find new Mersenne prime numbers. If you’re good at math, that’s: Mn = 2n – 1. The applications used in this article to test WSRM are two different versions of Prime95, renamed Application1 and Application2 respectively. It’s not possible to run multiple instances of the Prime95 executable, but you can run the latest version and an older version at the same time. (Prime95 is available at www.mersenneforum.org.) For testing CPU management, I set Prime95’s Run a Torture Test setting to Small FFTs; and for memory testing, I set it to Blend.
Ease of Use and Instant Results
WSRM uses Resource Allocation Policies to dynamically assign processor resources and limit memory consumption. There are four predefined Resource Allocation Policies that can be used to manage server resources easily without any configuration. Equal_Per_Process divides processor resources equally between applications when overall CPU utilization is above 70 percent. Equal_Per_User groups processes by the user account under which they run, and then shares CPU time evenly between each group of processes. Equal_Per_Session groups processes by terminal service session and Equal_Per_IISAppPool groups by IIS application pool.
You can make any one of these default Resource Allocations Policies active by opening WSRM from Administrative Tools on the Start menu, expanding Resource Allocation Policies in the left pane, right clicking the policy you want to make active and selecting Set as Managing Policy from the menu. WSRM includes a list of processes that are excluded from management by default, and you can add to this list by right clicking Windows System Resource Manager (Local), selecting Properties from the menu and then switching to the Exclusion List tab.
Creating a Resource Application Policy
Let’s create our own policy to get a better understanding of how WSRM works. In this simple scenario there are two applications, Application1 and Application2, both competing for maximum processor resources. Application1 is a mission-critical application, and must be given priority access to CPU resources.
Log on as Administrator and open WSRM from Administrative Tools on the Start menu:
- Select This computer in the Connect to computer dialog and click OK.
- To make our testing a little simpler, let’s deactivate WSRM’s scheduling features by disabling the calendar. Right click Windows Server Resource Manager (Local),and on the Management tab, set Calendar to Disabled in the drop-down menu and click OK.
- Right click Process Matching Criteria in WSRM’s left pane and select New Process Matching Criteria from the menu. Process Matching Criteria are used to define processes or groups of processes, which are managed by a given Resource Allocation Policy.
- In the Criteria Name box, type Application1. In the Rules section, click Add and on the File or Command Lines tab, select Application from the menu. Click Select on the right of the menu and browse to the Application1 executable and click Open. Click OK on the Add Rule dialog (Figure 1).
- Expand Process Matching Criteria in the left pane, and you should see a new entry called Application1, along with the two standard criteria, Residual and IISAppPool.
- Right click Resource Allocation Policy in the left pane and select New Resource Allocation Policy from the menu.
- Type Application1 in the Policy Name field. Click Add under Allocate these resources and select Application1 as the Process Matching Criteria from the drop-down menu.
- Let’s allocate 85 percent of processor resources to Application1 and then click OK.
- The Properties dialog now should show Application1 as being assigned 85 percent of CPU resources (Figure 2). Click OK to continue.
- Expand Resource Allocation Policies in the left pane, right click the new Application1 policy and click Select as Managing Policy on the menu. Only one Resource Allocation Policy can be active at any one time, although the active policy can be changed automatically according to WSRM’s Calendar or Conditions.
Now that our Resource Allocation Policy has been created, let’s run Application1 and Application2 together to see if WSRM successfully allocates CPU resources in favor of Application1.
- Make sure that WSRM is turned on by checking for the Play symbol (a green triangle) on the left of Windows System Resource Manager (Local) in the left pane (Figure 3). If you see the Stop symbol (a red square), right click Windows System Resource Manager (Local) and select Starts Windows System Resource Manager management from the menu.
- Open Task Manager by pressing CTRL+ALT-DEL and select Start Task Manager from the options given. Launch Application1 and Application2 (two different versions of Prime95 with the Small FFTs option set at startup).
- Click the CPU column in Task Manager until the arrow points downward. This sorts processes according to the amount of CPU resources being used, with processes consuming the highest resources listed at the top. Figure 4 shows WSRM allocating proportionately more CPU time to Application1.
- Go back to the WSRM MMC, right click Windows System Resource Manager (Local) in the left pane and select Stops Windows System Resource Manager management from the menu.
- Task Manager should now show both applications competing equally for CPU resources (Figure 5).
Controlling Memory Leaks
Let’s modify our Resource Allocation Policy and configure it to terminate Application1 if it uses more than 200MB.
- In WSRM expand Resource Allocation Policies, right click the Application1 policy and select Properties from the menu.
- Application1 will be highlighted under Process Matching Criteria. Click Edit to continue.
- Switch to the Memory tab and check Use maximum committed memory for each process. Enter 200 in the memory limit box and set Stop the application as the action performed if memory is surpassed. Click OK twice.
- Start Application1 (Prime95) with the Blend option and after a few seconds WSRM will terminate Application1.
- Open Event Viewer from Administrative Tools on the Start menu and check for Event ID 702 in the Application event log (Figure 6).
Windows Server Resource manager is included in all editions of Windows Server 2008 and provides instant value for heavily loaded terminal and web servers with its predefined Resource Allocation Policies. For more granular control of server resources, it’s easy to create new policies, which can be swapped in and out according to a schedule, helping to tune server performance according to demand at peak periods. Important users can be given priority for applications running locally or through Terminal Services. WSRM is a useful tool for improving server performance and in certain scenarios can help increase the return on investment from your server hardware.