introducing sql server 2008 r2 resource governor

Download Introducing SQL Server 2008 R2 Resource Governor

Post on 30-Oct-2014




0 download

Embed Size (px)



SQL Server 2008 Resource GovernorKiki Rizki NoviandiSQL Server MVP Blogs : Email :

Session Objectives And AgendaWhat Resource Governor isScenarios covered Limitations in scope and scenarios

Concepts and details CPU Demo Feedback, Q&A

Overall Picture: SQL Server 2005Workloads

Call routing





All Server Resources

Where Resource Governor Can HelpRun-away query scenarioPrevent or minimize possibility if possible

Predictable concurrent execution of different-size workloadsProvide mission critical workloads resources they need Limit known large workloads from abusing resources

Workload prioritization

Resource Governor GoalsAbility to differentiate workloads Ability to monitor resource usage per group Limit controls to allow throttled execution or prevent/minimize probability of run-aways Realize user preference on what is important

Overall Picture: SQL Server 2008Workloads, Batch controls

Call routing





Pool 1

Part of the server, Aggregate resource controls

Pool 2

Resource Governor LimitationsDatabase Engine onlyAnalysis Services, Reporting Services, etc. are covered as regular applications to SQL Server database engine

Single instance onlyEach instance controlled individually Can be combined with Windows Server Resource Manager (WSRM)

Controls for CPU bandwidth and MemoryMemory: anything that goes through Single Page Allocator SOS API No I/O for the next release

Resource Governor in SQL MS

Catalog view & Dynamic ManagementThere are three new Catalog Views and three new Dynamic Management Views introduced for Resource Governor.sys.resource_governor_configuration - used to display the Resource Governor configuration as stored in metadata. sys.resource_governor_resource_pools - used to display resource pool configuration as stored in metadata. sys.resource_governor_workload_groups - used to display workload group configuration as stored in metadata. sys.dm_resource_governor_configuration - used to get the current in-memory configuration state of Resource Governor sys.dm_resource_governor_resource_pools - used to get the current resource pool state, the current configuration of resource pools, and resource pool statistics. sys.dm_resource_governor_workload_groups - used to get the workload group statistics and the current in-memory configuration of the workload group.

Demo: CPU Bandwidth and Importance controls

Demo : Setting up RGUSE master; GO -- Examine the current configuration SELECT * FROM sys.dm_resource_governor_configuration; GO

--Define two resource pools, one with 10% CPU max, and the other with 90% CREATE RESOURCE POOL MarketingPool WITH (MAX_CPU_PERCENT = 10); GO

CREATE RESOURCE POOL DevelopmentPool WITH (MAX_CPU_PERCENT = 90); GO-- Look at our configuration SELECT * FROM sys.dm_resource_governor_resource_pools; GO

Demo : Setting up RG-- Need to reconfigure ALTER RESOURCE GOVERNOR RECONFIGURE; GO SELECT * FROM sys.dm_resource_governor_resource_pools; GO

-- Add two workload groups CREATE WORKLOAD GROUP MarketingGroup USING MarketingPool; GOCREATE WORKLOAD GROUP DevelopmentGroup USING DevelopmentPool; GO

-- Look at our configuration SELECT * FROM sys.dm_resource_governor_workload_groups; GO

Demo : Setting up RG-- Need to reconfigure again ALTER RESOURCE GOVERNOR RECONFIGURE; GO SELECT * FROM sys.dm_resource_governor_workload_groups; GO


Create some dummy databases. The classifier function will use the database name in the connection string to decide which group to put the connection in. DB_ID ('MarketingDB') IS NULL CREATE DATABASE MarketingDB;DB_ID ('DevelopmentDB') IS NULL CREATE DATABASE DevelopmentDB;

-- Define a classifier function IF OBJECT_ID ('dbo.MyClassifier') IS NOT NULL DROP FUNCTION dbo.MyClassifier; GO

Demo : Setting up RGCREATE FUNCTION dbo.MyClassifier () RETURNS SYSNAME WITH SCHEMABINDING AS BEGIN DECLARE @GroupName SYSNAME; IF ORIGINAL_DB_NAME () = 'MarketingDB' SET @GroupName = 'MarketingGroup'; ELSE IF ORIGINAL_DB_NAME () = 'DevelopmentDB' SET @GroupName = 'DevelopmentGroup'; ELSE SET @GroupName = 'Default'; RETURN @GroupName; END; GO -- Register it ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = dbo.MyClassifier); GO ALTER RESOURCE GOVERNOR RECONFIGURE; GO

Demo : Setting up RG-- Look at our configuration again SELECT * FROM sys.dm_resource_governor_configuration; GO -- Now open System Monitor, Action | New Window From Here. -- Add the SQLDEV01 Resource Pools counters for Marketing and Development -- Run -- sqlcmd /E /S.\SQLDEV01 /d /iRunQueries.sql -- Do marketing first and then development

RunQueries.sqlIF OBJECT_ID ('t1') IS NOT NULL DROP TABLE t1; GO CREATE TABLE t1 (c1 INT, c2 VARCHAR (8000)); CREATE CLUSTERED INDEX t1c1 ON t1 (c1); GO SET NOCOUNT ON; GO DECLARE @count INT; SET @count = 0; WHILE (@count < 1000) BEGIN INSERT INTO t1 VALUES (@count, REPLICATE ('a', 8000)); SET @count = @count + 1; END;

-- This won't do an -- and doesn't have -- it processes the WHILE (1 = 1) ALTER

physical IOs (as the index is in the buffer pool any fragmentation) but it will spin the CPU while index. INDEX t1c1 ON t1 REORGANIZE;


2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


View more >