Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

SQL SErver 2008 : Resource Governor in action

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
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.

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)
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server