The Resource Governor was introduced to SQL Server 2008 to provide predictable performance for mission-critical workloads.. Resource Governor achieves predictable performance by monitor
Trang 1customers, realizing many benefits of better hardware utilization and more
cost-effective database deployments However consolidation does have some drawbacks
The most common objections to server consolidation is performance, because shared (multi-instance) servers and shared SQL Server instances can introduce challenges in
ensuring consistent performance for all database users Common problems arise from mixed users where regular OnLine Transaction Processing (OLTP) users mix with
reporting users on the same instance; examples can be found where databases for the
finance department combine with sales order databases In this situation, normal
database traffic consisting of inserts, updates, and deletes can conflict with the
work-load generated by reports run by finance users executing month- or year-end reports based on historic sales data
The Resource Governor was introduced to SQL Server 2008 to provide
predictable performance for mission-critical workloads Resource Governor
achieves predictable performance by monitoring and reserving minimum levels of
critical resources such as CPU and memory for specific tasks or groups of tasks
Resource Governor Concepts
The Resource Governor consists of three key concepts: Resource Pools, Workload
Groups, and Classification Functions The Resource Governor exists to manage
minimum resources available for different groups of users or tasks However the
governor is more intelligent than simply dividing resources among users; if resources
are unused elsewhere on a server, a given user can be permitted to use excess of their
quota (up to a maximum allocation) until a time when another user or process
requires the resource (memory or CPU)
This section introduces each concept and uses an example to illustrate the purpose and implementation of the concept The example relates to a college whereby requests
from lecturers should receive priority over requests received from students
Resource Pools
Resource pools are used to manage minimum and maximum restrictions on physical server resources Conceptually, Resource Pools enable multiple virtual SQL Server
instances to operate within a single physical instance Each pool (virtual instance)
is allocated a minimum and maximum CPU and memory resources There is a limit
of 18 custom resource pools in addition to the two resource pools created when
SQL Server 2008 is installed:
INTERNAL: Use for SQL Server internal system processes
■
■
DEFAULT: Used by workloads unassigned to any workload group
■
■
Trang 2The combination of minimum values across all pools cannot exceed 100% and the maximum value can be anywhere between the minimum value and 100% In addition to Min and Max settings, Resource pools have two further calculated val-ues; Effective Maximum and Shared % (see Table 13.10) The Effective Maximum is determined by calculating the max value of a Resource pool and the minimum values of all other Resource pools The internal pool has highest priority of all Resource pools since this is where internal processes are handled; it is not exposed
to effective or share maximums
Resource
Calculated Effective Max % Calculated Shared %
Effective Max Calculation Explained
Shared % Calculation Explained
applicable
to internal pool
Not applicable
to internal pool
100–50) = 50 50–0=50
100–40) = 60 60–10=50
100–15) = 85 85–35=10
100–45) = 55 55–5=50
Table 13.10 Resource Pool Calculated Values
The following T-SQL can be used to create two resource pools, the first for lecturers and the second for students:
CREATE RESOURCE POOL rscpLecturers
WITH
( MAX_CPU_PERCENT = 100,
MIN_CPU_PERCENT = 50)
GO
CREATE RESOURCE POOL rscpStudents
WITH
Trang 3MIN_CPU_PERCENT = 0)
GO
Workload Groups
The Workload Group makes managing the Resource Governor easier The
Workload Group makes it easier to assign user session requests to a specific
resource pool Workload groups also make it easier to monitor resource consumption within each Resource pool Workload groups may be moved between Resource
pools by the administrator if a particular Resource pool becomes too busy or
overloaded
Similar to Resource pools, administrators can create their own Workload
Groups and there are two groups created when SQL Server is installed:
INTERNAL: Use for internal SQL Server operations
■
■
DEFAULT: All unassigned session requests are serviced by this
■
■
workload group
Here’s the T-SQL required to create a group for two workload groups:
CREATE WORKLOAD GROUP grpLecturers
WITH
(IMPORTANCE = MEDIUM)
CREATE WORKLOAD GROUP grpStudents
WITH
(IMPORTANCE = LOW)
Classification Function
The classification function is created to identify incoming requests to SQL Server
and map these incoming requests to a workload group The classification function is
a user-defined function (UDF) and is created as a scalar valued function The
function can use any valid property to classify a new session, such as Username,
Hostname, or IP address
Only one UDF can be designated as a classifier at any one time Consider
performance of the UDF when creating the function since it will be used to
evaluate every incoming session The Dedicated Administrator Connection
(DAC) is not exposed to classification; as such the DAC can be used to
trouble-shoot performance problems relating to classification Once the classifier function
has been defined, it should be assigned to the Resource Governor, followed by
the reconfigure statement:
Trang 4ALTER RESOURCE GOVERNOR
WITH (CLASSIFIER_FUNCTION = dbo.func_Session_Classifier)
Configuring & Implementing…
Always Enable DAC
When Using Resource Governor
All new sessions are subject to the classification function Enable Dedicated Admin Connection to provide access for troubleshooting since this connection
is not subject to classification.
Validate Configuration
The Resource Governor should be enabled before use (is disabled by default) Configuration changes can be made dynamically and don’t require a service restart, however the following instruction should be used after any changes to bring these into effect:
ALTER RESOURCE GOVERNOR RECONFIGURE
Use the following DYNAMIC Management Views (DMVs) to verify configuration
is as intended:
sys.dm_resource_governor_resource_pools
sys.dm_resource_governor_workload_groups
Resource Governor Summary
The Resource Governor is an important new feature to manage resource allocation among groups of users The following simplified pseudo-steps illustrate the process an incoming session steps through in order to be allocated resources by the governor:
1 Session begins
2 Classification function executes
3 Workload Group membership determined; otherwise use Default
4 Query executes within specified resource pool
Trang 5Summary of Exam Objectives
This chapter provided an overview of performance tuning in SQL Server 2008,
including an introduction to tracing with SQL profiler, an overview of locking and
blocking, the basics of Dynamic Management Views and Performance Data
Collection Additionally we looked at how the Resource Governor can be used to
manage mixed workloads to ensure minimum resource availability
We also looked at table partitioning – a technology useful when maintenance
(backup, reindexing, checkdb) become cumbersome with particularly large tables
Partitioning provides the option to separate a large table into a number of smaller
tables – which is completely transparent to the application
Exam Objectives Fast Track
Tracing
Use SQL Profiler to capture the statements being executed on a server for
Ü
performance review/ analysis
There can be an overhead with running traces, consider how many events
Ü
you capture, any filters you apply and where the trace is run
Trace data saved directly to a database or to a file then imported into a
Ü
database for easier analysis
Locks, Blocking, and Deadlocks
Locking and blocking is normal in a database – but if frequency is excessive
Ü
they can lead to performance problems
Deadlocks are always damaging for performance – use SQL Profiler to
Ü
capture a trace or enable traceflag 1222 for more details about the processes
involved in deadlocking, then address the cause
Consider the transaction isolation level and indexing to ensure processes
Ü
use appropriate locking mechanisms based on their requirements
Guide to the Dynamic Management Views
DMVs and Dynamic Management Functions (DMFs) provide a view on
Ü
SQL Server internals and can be used for troubleshooting and fault diagnosis