09.11.2014 Views

Beatrice Nicolini.pdf - TechNet Blogs

Beatrice Nicolini.pdf - TechNet Blogs

Beatrice Nicolini.pdf - TechNet Blogs

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Session Code: DAT301<br />

SQL Server 2008<br />

Resource Governor<br />

<strong>Beatrice</strong> <strong>Nicolini</strong><br />

Premier Field Engineer<br />

Microsoft<br />

http://blogs.technet.com/beatrice<br />

email: beatrice.nicolini@microsoft.com<br />

2


Agenda<br />

Prior to Resource Governor<br />

Introducing SQL Server 2008 Resource Governor<br />

Scenarios<br />

Concepts<br />

Monitoring<br />

Demo 1<br />

Limitations<br />

CPU Considerations<br />

Demo 2<br />

Usage Scenarios<br />

Get Started!<br />

3


Prior to Resource Governor<br />

Control memory, CPU, I\O<br />

Affinity on a per instance basis<br />

Query Governor on a per<br />

query basis<br />

If the estimated cost of a query<br />

exceeds the threshold, it won’t<br />

be allowed to run at all!<br />

If statistics out of date –<br />

incorrect estimate<br />

4


Introducing Resource Governor<br />

Scenarios<br />

Protect from<br />

known large<br />

resource<br />

consumers<br />

Guarantee<br />

resources for<br />

mission critical<br />

workloads<br />

Compete for<br />

resources as usual<br />

(SQL Server 2005<br />

behavior)<br />

5<br />

Predictable Workload<br />

CPU – Memory<br />

Enterprise, Developer and Evaluation Edition


Introducing Resource Governor<br />

Concepts<br />

DAC<br />

Incoming Sessions<br />

Classification<br />

Internal<br />

Group<br />

Default<br />

Group<br />

Group 1 .... Group N<br />

Internal Pool Default Pool Pool 1 Pool N<br />

6


Configuring Resource Governor<br />

After install Resource Governor is available but is not<br />

enabled.<br />

Internal and default Resource Pools and Workload<br />

Groups are already created<br />

Configure Resource Governor:<br />

Resource pools<br />

Create a workload groups<br />

Define and activate a classifier function<br />

7


Introducing Resource Governor<br />

Concepts – Resource Pool<br />

A resource pool, or pool,<br />

represents the physical resources<br />

of the server.<br />

LIMITATIONS\WARNINGS<br />

- Limited to 20 pools<br />

- CPU% Applied per scheduler<br />

8


Syntax<br />

Resource Pool<br />

CREATE RESOURCE POOL pool_name<br />

WITH (<br />

MIN_CPU_PERCENT = value,<br />

MAX_CPU_PERCENT = value,<br />

MIN_MEMORY_PERCENT = value,<br />

MAX_MEMORY_PERCENT = value<br />

)<br />

9


10<br />

Syntax<br />

GUI


Introducing Resource Governor<br />

Concepts – Workload Group<br />

A workload group serves as a<br />

container for session requests<br />

that are similar according to the<br />

classification criteria that are<br />

applied to each request.<br />

No max limitation<br />

Internal Group<br />

Default Group<br />

(All Other<br />

Applications Users)<br />

Application 1 Users<br />

Application 2 Users<br />

Administrators<br />

Group<br />

Internal Pool Default Pool Pool 1 Pool N<br />

11


Syntax<br />

Workload Group<br />

CREATE WORKLOAD GROUP grp_name<br />

WITH (<br />

IMPORTANCE = {LOW | MEDIUM | HIGH},<br />

REQUEST_MAX_MEMORY_GRANT_PERCENT = value,<br />

REQUEST_MEMORY_GRANT_TIMEOUT_SEC = value,<br />

REQUEST_MAX_CPU_TIME_SEC = value,<br />

MAX_DOP = value,<br />

GROUP_MAX_REQUESTS = value)<br />

[ USING { pool_name | "default" } ] [ ; ]<br />

12


What is Importance?<br />

Importance is weight (L:M:H = 1:3:9) used from tasks in<br />

different groups when groups share a pool.<br />

1 Pools – 2 Groups<br />

MAX CPU unrestricted<br />

Without Importance<br />

1 Pools – 2 Groups<br />

MAX CPU unrestricted<br />

Imp = low – Imp=high<br />

Group 1 CPU Usage: 50%<br />

Group 2 CPU Usage: 50%<br />

Pool CPU: 100%<br />

SQL Server CPU: 100%<br />

Group 1 CPU Usage: 10%<br />

Group 2 CPU Usage: 90%<br />

Pool CPU: 100%<br />

SQL Server CPU: 100%<br />

13


Introducing Resource Governor<br />

Concepts - Classifier<br />

The classifier is a UDF that is<br />

fired right after the login triggers<br />

and before the T-SQL debugger<br />

is enabled during login.<br />

BE AWARE\CLARIFICATION:<br />

• Part of the login process logins can timeout<br />

•Classification failure or no classification criteria default group.<br />

•Cannot change group binding after initial assignment<br />

• Cannot specify in T-SQL which group to go to (aka “explicit” classification)<br />

• 1 per time<br />

14


Syntax - UDF<br />

HOST_NAME(), APP_NAME(), SUSER_NAME(), SUSER_SNAME(),<br />

IS_SRVROLEMEMBER(), IS_MEMBER(), LOGINPROPERTY ,<br />

ORIGINAL_DB_NAME, CONNECTION PROPERTY function<br />

EXAMPLE:<br />

CREATE FUNCTION dbo.rgclassifier_v3 ()<br />

RETURNS sysnameE<br />

WITH SCHEMABINDING AS<br />

BEGIN<br />

DECLARE @grp_name sysname<br />

IF suser_sname() = 'DOMAIN\username'<br />

SET @grp_name = 'MyGroup'<br />

RETURN @grp_name<br />

END; GO<br />

COMMIT TRAN; GO<br />

15


Monitoring Resource Governor<br />

Performance<br />

Counters<br />

DMVs<br />

Catalog<br />

Views<br />

Events<br />

16


Monitoring Resource Governor<br />

Dedicated Administrator Connection<br />

(DAC) to troubleshoot UDF<br />

DAC is not subject to classification<br />

DAC can be used while Resource Governor is<br />

running and classifying incoming sessions.<br />

If a DAC is not available restart the<br />

system in single user mode.<br />

17


18<br />

<strong>Beatrice</strong> <strong>Nicolini</strong><br />

Premier Field Engineer<br />

Microsoft


Resource Governor Limitations<br />

• limited to the SQL Server Database Engine.<br />

• Limit specification applies to CPU and memory<br />

• Cannot change group binding after initial assignment<br />

• Cannot specify in T-SQL which group to go to (aka<br />

“explicit” classification)<br />

• No automatic actions on various timeouts<br />

19


CPU Considerations<br />

Scheduling decision is<br />

made on per scheduler<br />

basis<br />

CPU usage limited only<br />

under contention!<br />

You need multiple tasks in<br />

different groups/pools to<br />

observe effect<br />

Remember when<br />

troubleshooting\monitoring<br />

20


CPU Considerations<br />

1 Pool<br />

Min CPU 0<br />

MAX CPU 100<br />

1 Group<br />

1 Task<br />

1 Pool<br />

Min CPU 0<br />

MAX CPU 80<br />

1 Group<br />

1 Task<br />

2 Pools A & B<br />

Min CPU 20<br />

MAX CPU 80<br />

2 Group s<br />

2 Task<br />

Modify Pool A<br />

Min CPU 20<br />

MAX CPU 40<br />

2 Groups<br />

2 Task<br />

21


Demo Title<br />

<strong>Beatrice</strong> <strong>Nicolini</strong><br />

Premier Field Engineer<br />

Microsoft<br />

22


23<br />

Typical Scenario - Backup Compression<br />

Before 2008: Third party vendors solution.<br />

Backup Compression:<br />

- Reduced Storage Space<br />

- Similar compression ratios as<br />

vendors software (5:1)<br />

- Proprietary Algorithm<br />

- Reduced Network Bandwidth<br />

- Reduced run-time for backup\restore<br />

- Off by default<br />

- Enterprise Only


Test on 322 Mb Database<br />

45% RunTime improvement<br />

4.2x Compression ratio<br />

50% RunTime improvement<br />

24


Typical Scenario<br />

Limit CPU Usage by Backup Compression<br />

Backup compression significantly<br />

increases CPU usage<br />

Create a low-priority compressed backup<br />

Setting Up a Login and User for Low-Priority<br />

Operations<br />

Configuring Resource Governor to Limit CPU Usage<br />

Verifying the Classification of the Current Session<br />

(Transact-SQL)<br />

Compressing Backups Using a Session with Limited<br />

CPU<br />

25


Typical Scenario<br />

Limit CPU Usage by Backup Compression<br />

26


Typical Scenario<br />

Reporting Solution<br />

Create a high priority login for<br />

reporting applications!<br />

27


Typical Scenario<br />

Reporting Solution<br />

28


Typical Scenario<br />

Admins<br />

Guarantee that the admin group:<br />

• always has resources to run diagnostic queries<br />

• these queries should not take more than N% of the<br />

server memory resources.<br />

29


Typical Scenario<br />

Admins<br />

30


Get Started!<br />

Who’s consuming my resources?<br />

Create workload groups to<br />

monitor resource<br />

consumption<br />

Monitor consumption<br />

Based on monitoring, create<br />

pools and associate your<br />

groups accordingly<br />

31


Summary<br />

Call-to-action<br />

Resource Governor is a feature than enables<br />

DBAs to provide a consistent and predictable<br />

response to SQL Server workloads and system<br />

resource consumption (CPU, Memory).<br />

Get started – create and test your workloads<br />

and tune your pools for improved control!<br />

32


Resources for IT Professionals<br />

www.microsoft.com/teched<br />

Tech·Talks<br />

Live Simulcasts<br />

Tech·Ed Bloggers<br />

Virtual Labs<br />

http://microsoft.com/technet<br />

Evaluation licenses, pre-released<br />

products, and MORE!


34<br />

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.<br />

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should<br />

not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,<br />

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!