• Resource Governor was added in SQL Server
2008
• Purpose is to manage resources by specifying limits on consumption of those resources by the requests processes that are using them.
• Resource Governor is available in Enterprise,
Developer, and Evaluation Editions of SQL
Server 2008 and greater
• Intrusive queries that consume a lot of the resources
• Unpredictable workload due to a workload type mixture. For example OLTP & DSS running on the same instance
• Workload priority can be set to ensure higher priority processes get more resources
• The ability to classify connections and route the workload to a specific group
• The ability to monitor resource usage for each workload in a group
• The ability to pool resources and set pool specific limits on CPU and memory.
• The ability to associate grouped workloads with a specific pool of resources
• The ability to set priorities for workloads
• Limited to SQL Server Engine Only
• Self contained within a SQL Server. In other words, one instance doesn’t know about resource usage in another instance
• Applies to only CPU and memory usage only
• OLTP workloads are typically short in duration and can skew statistics.
• Resource Pools
• Workload Groups
• Classification
• Represents physical resources of a database instance
• Types Of Pools
– internal pool (can not be altered, created by default)
– default pool (first predefined user pool, can not be dropped, but can be altered, created by default)
– user defined pool (Can create up to 18)
• Two Parts
– Minimum resource reservation - Minimum guaranteed availability of the pool
– Maximum resource reservation – Maximum size of the pools
• The sum of MIN values across all pools can not exceed 100% of the instance resources
• The MAX values can be set anywhere between MIN and 100%
Pool name
MIN % setting
MAX % setting
Calculated effective MAX
%
Calculated shared % internal 0 100 100
Comment
0
Effective MAX % and shared % are not applicable to the internal pool.
default
Pool 1
0
20
100
100
25
45
The effective MAX value is calculated as:
25 min(100,100-(20+50+5)) = 25. The calculated shared % is Effective MAX -
MIN = 25.
The effective MAX value is calculated as:
25 min(100,100-55) = 45. The calculated
Shared % is Effective MAX - MIN = 25.
Pool 2
Pool 3
50
5
70
100
70
30
The effective MAX value is calculated as:
20 min(70,100-25) = 70. The calculated
Shared % is effective MAX - MIN = 20.
The effective MAX value is calculated as:
25 min(100,100-70) = 30. The calculated
Shared % is effective MAX - MIN = 25.
• A container for session requests that are similar to how they are classified.
This is where the policy is defined for all members of the group.
• Types Of Groups
– Internal – created by default and can not be modified
– Default – group where members are placed by default under the following conditions
• No classification for a request
• Attempt to classify into a non-existent group
• Any generic classification failure
• What can be controlled by a workload group
– Maximum amount of memory for a request
– Maximum percentage of CPU for use
– Resource time-out for a request
– Priority
– Maximum number of requests
– Maximum degree of parallelism
• Based on rules that are part of a function that classify a connection into a workload group. You can not classify anything into the internal workload group.
• Steps To Get Classification Working
– Write a scalar function that has the logic that assigns the session to a workload group
– Register the function using the alter resource governor statement
– Update the resource governor with the reconfigure option
• Must be a scalar function (one and only one result)
• Evaluated for every new session
• Once workload group membership is determined, the connection is bound to that group for the its lifetime
• Function must be defined in the master database
• Only one function can be used by the resource governor at a time
• If the function is dropped, then all sessions are bound to the default group.
• Any connection using the Dedicated Admin Connection is not subject to the resource governor.
• System views sys.resource_governor_configuration
sys.resource_governor_resource_pools
sys.resource_governor_workload_groups
Returns the stored Resource Governor state.
Returns the stored resource pool configuration. Each row of the view determines the configuration of a pool.
Returns the stored workload group configuration.
• Dynamic Management Views sys.dm_resource_governor_workload_groups
Returns workload group statistics and the current in-memory configuration of the workload group.
sys.dm_resource_governor_resource_pools
sys.dm_resource_governor_configuration
Returns information about the current resource pool state, the current configuration of resource pools, and resource pool statistics.
Returns a row that contains the current in-memory configuration state for
Resource Governor.
• Perfmon Counters
SQLServer:Workload Group Stats
Reports statistics for each active workload group, such as the number of active requests and the number of blocked requests.
SQLServer:Resource Pool Stats
Reports statistics for each active resource pool, such as the number of memory grants that are occurring in the resource pool per second and the amount of memory that is used by the resource pool.