Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Server

SQL SErver 2008 : Resource Governor in action

11/7/2012 3:46:28 PM

1. Resource Governor in action

Now that you have a solid understanding of the components that make up Resource Governor, let's walk through an example of its implementation. Let's imagine we have a database used for both a production point-of-sales application and as a source for a reporting system. Our goal is to constrain the CPU and memory resources consumed by the reporting system in order to reduce the impact on the point-of-sales system when large reports are executed.

Let's walk through the T-SQL code for creating the necessary components, beginning with the creation of the workload groups, as shown in listing 1.

Example 1. Creating workload groups
-- Create 2 Workload Groups
USE MASTER
GO


CREATE WORKLOAD GROUP RG_Reporting
GO
CREATE WORKLOAD GROUP RG_Sales
GO

Despite the various options available, we create our workload groups with all of the default settings. Next up, we'll create the classifier function used to assign incoming connections to the appropriate group. After the function is created, we'll configure Resource Governor to use it, as shown in listing 16.3.

Example 16.3. Classifier function
-- Create a Classifier Function
CREATE FUNCTION ClassifierFn_Basic() RETURNS SYSNAME WITH SCHEMABINDING AS
 BEGIN
   DECLARE @ResGroup AS SYSNAME
   IF (SUSER_NAME() = 'reporting')
      SET @ResGroup = 'RG_Reporting'
   IF (SUSER_NAME() = 'sales')
      SET @ResGroup = 'RG_Sales'
   RETURN @ResGroup
END
GO

-- Configure Resource Governor to use the new function
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION=dbo.ClassifierFn_Basic)
GO

In this example, our classifier function uses the login name via the SUSER_NAME() function as the basis for classification. As we explained earlier, this could be based on the application, host, or role membership using the appropriate function.

Our final step is to create the resource pools and assign them to the appropriate workload groups, as per listing 2.

Example 2. Assigning resource pools to workload groups
-- Create a new Resource Pool
CREATE RESOURCE POOL RP_Sales WITH (
    MIN_CPU_PERCENT = 40
    , MAX_CPU_PERCENT = 60
    , MIN_MEMORY_PERCENT = 40
    , MAX_MEMORY_PERCENT = 60
)
GO

-- Configure a Workload Group to use the new Resource Pool
ALTER WORKLOAD GROUP RG_Sales USING RP_Sales
GO

-- Create a new Resource Pool
CREATE RESOURCE POOL RP_Reporting WITH (
    MIN_CPU_PERCENT = 5
    , MAX_CPU_PERCENT = 15
    , MIN_MEMORY_PERCENT = 5
    , MAX_MEMORY_PERCENT = 15
)
GO

-- Configure a Workload Group to use the new Resource Pool
ALTER WORKLOAD GROUP RG_Reporting USING RP_Reporting
GO

In the above example, we've created resource pools with minimum and maximum CPU and memory values. At this point, the only step left is to reconfigure the Resource Governor to enable the new settings. We can do this using the following command:

-- Reconfigure the Resource Governor to enable the new settings
ALTER RESOURCE GOVERNOR RECONFIGURE
GO

Once the above T-SQL has been executed, we can confirm our settings using SQL Server Management Studio by right-clicking Resource Governor and choosing Properties. The resultant screen, as shown in figure 1, allows us to modify the settings should we wish to do so.

Finally, should we wish to disable Resource Governor, we can do so using the following command:

-- Disable the Resource Governor
ALTER RESOURCE GOVERNOR DISABLE
GO

Figure 1. You can use the properties window of Resource Governor to select the classifier function and view or edit the resource pools and workload groups settings.
 

To complete our coverage of Resource Governor, let's review some of the monitoring options available.

Top Search -----------------
- Windows Server 2008 R2 : Work with RAID Volumes - Understand RAID Levels & Implement RAID
- Windows Server 2008 R2 Administration : Managing Printers with the Print Management Console
- Configuring Email Settings in Windows Small Business Server 2011
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Implement Permissions
- Monitoring Exchange Server 2010 : Monitoring Mail Flow
- Windows Server 2008 R2 :Task Scheduler
- Windows Server 2008 R2 : File Server Resource Manager
- Windows Server 2008 R2 : Installing DFS
- Exchange Server 2010 : Managing Anti-Spam and Antivirus Countermeasures
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Share Folders
Other -----------------
- SQL SErver 2008 : Resource Governor - Workload groups, Resource pools
- Windows Server 2008 Server Core : emoving Files with the Del and Erase Commands, Compressing Files with the Diantz and MakeCab Utilities
- Windows Server 2008 Server Core : Comparing Two Files with the Comp Utility, Copying Files with the Copy Command
- Microsoft Lync Server 2010 Monitoring : Configuration
- Windows Server 2008 R2 file and print services : Administering File Shares (part 3) - Publishing shared folders to Active Directory
- Windows Server 2008 R2 file and print services : Administering File Shares (part 2) - Securing shared folders
- Windows Server 2008 R2 file and print services : Administering File Shares (part 1) - Creating shared folders
- SQL Server 2008 R2 : A Performance and Tuning Methodology (part 4) - Tools of the Performance and Tuning Trade
- SQL Server 2008 R2 : A Performance and Tuning Methodology (part 3) - Performance and Tuning Design Guidelines
- SQL Server 2008 R2 : A Performance and Tuning Methodology (part 2)
 
 
Most view of day
- Windows Server 2008 Server Core : Compressing Data with the Compact Utility
- Manage the Active Directory Domain Services Schema : Remove Attributes from the Index
- Add an InfoPath Form Web Part to a SharePoint Web Part Page
- Microsoft Systems Management Server 2003 : Defining Parent-Child Relationships (part 2) - Installing the Secondary Site Locally from the SMS CD
- Windows Server 2003 : Analyzing Traffic Using Network Monitor (part 1)
- BizTalk 2009 : Host Integration Server 2009 - Planning Your Host Integration Server Topology
- Using Windows Live Programs (part 2) - Using Windows Live Mail
Top 10
- Automating Windows 7 Installation : Customizing Images Using Deployment Image Servicing and Management (part 3) - Servicing the Operating System in an Image , Committing an Image
- Automating Windows 7 Installation : Customizing Images Using Deployment Image Servicing and Management (part 2) - Mounting an Image , Servicing Drivers in an Image
- Automating Windows 7 Installation : Customizing Images Using Deployment Image Servicing and Management (part 1) - Viewing Information about an Image with DISM
- Automating Windows 7 Installation : Applying an Image Using ImageX
- Automating Windows 7 Installation : Capturing an Image Using ImageX
- Microsoft Visio 2010 : Creating Web Pages from Visio Drawings (part 4) - Fine-tuning Web Pages and Battling Bugs - Saving a Visio Drawing as a Web Page
- Microsoft Visio 2010 : Creating Web Pages from Visio Drawings (part 3) - Fine-tuning Web Pages and Battling Bugs - Customizing Web Page Output
- Microsoft Visio 2010 : Creating Web Pages from Visio Drawings (part 2) - Exploring Visio-Generated Web Pages
- Microsoft Visio 2010 : Creating Web Pages from Visio Drawings (part 1) - Saving as Web Page
- Microsoft Visio 2010 : Sending Visio Files in Email, Saving as PDF or XPS Files
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro