Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Introducing

SQL Server 2008 Resource Governor


Kiki Rizki Noviandi
SQL Server MVP Blogs : Geeks.netindonesia.net/blogs/kiki Email : kiki.rizki.noviandi@live.com

Session Objectives And Agenda


What Resource Governor is
Scenarios covered Limitations in scope and scenarios

Concepts and details CPU Demo Feedback, Q&A

Overall Picture: SQL Server 2005


Workloads

Call routing

Admin

Ad-hoc

Reports

Marketing

All Server Resources

Where Resource Governor Can Help


Run-away query scenario
Prevent or minimize possibility if possible

Predictable concurrent execution of different-size workloads


Provide mission critical workloads resources they need Limit known large workloads from abusing resources

Workload prioritization

Resource Governor Goals


Ability 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 2008


Workloads, Batch controls

Call routing

Admin

Ad-hoc

Reports

Marketing

Pool 1

Part of the server, Aggregate resource controls

Pool 2

Resource Governor Limitations


Database Engine only
Analysis Services, Reporting Services, etc. are covered as regular applications to SQL Server database engine

Single instance only


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

Controls for CPU bandwidth and Memory


Memory: anything that goes through Single Page Allocator SOS API No I/O for the next release

Resource Governor in SQL MS

Catalog view & Dynamic Management


There 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 RG
USE 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; GO
CREATE 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

---IF GO IF 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 RG
CREATE 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<dbname> /iRunQueries.sql -- Do marketing first and then development

RunQueries.sql
IF 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;

Q&A

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

You might also like