1. Trang chủ
  2. » Công Nghệ Thông Tin

Microsoft SQL Server 2008 R2 Unleashed- P156 ppt

10 103 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 374,21 KB

Nội dung

ptg 1494 CHAPTER 40 Managing Workloads with the Resource Governor Reporting Sessions OLTP Sessions Classification (Classifier Function) Internal Group Internal Pool Group 1 Default Group Default Pool Pool 1 Group 2 Pool 2 Group 3 Group 4 Query Optimizer FIGURE 40.1 Overview of the Resource Governor. NOTE Resource Governor is available only in the Enterprise, Datacenter, and Developer Editions of SQL Server 2008 and SQL Server 2008 R2. Overview of Resource Governor Resource Governor works by controlling the allocation of resources according to work- loads. When a connection request is submitted to the Database Engine, the request is clas- sified based on a classification function. The classification function is a scalar function that you define via T-SQL. The classification function evaluates information about the connection (for example, login ID, application name, hostname, server role) to determine how it should be classified. After the connection request is classified, it is routed to a workload group defined for that classification (or if the connection cannot be classified, it is routed to the default workload group). Each workload group is associated with a resource pool. A resource pool represents the physical resources of SQL Server (currently in SQL Server 2008, the only physical resources available for configuration are CPU and memory) and specifies the maximum amount of CPU and/or memory resources that are to be allocated to a specific type of workload. When a connection is classified and put into the correct workload group, the connection is allocated the CPU and memory resources assigned to it, and then the query is passed on to the query optimizer for execution. This process is illustrated in Figure 40.1. ptg 1495 Resource Governor Components Resource Governor is designed to address the following types of resource issues, which are commonly found in a database environment: . Runaway queries—These resource-intensive queries can take up most or all of the server resources. . Unpredictable workload execution—This situation occurs when you have concurrent applications on the same server that are not isolated from each other, and the resulting resource contention causes unpredictable performance. . Workload prioritization—You might want to ensure that a critical workload is given priority to the system resources so it can process faster than other workloads or is guaranteed to complete if there is resource contention. In addition to enabling you to classify incoming connections and route their workloads to a specific group, Resource Governor also enables you to do the following: . Monitor resource usage for each workload in a group . Pool resources and set pool-specific limits on CPU usage and memory allocation, which can prevent or minimize the probability of runaway queries . Associate grouped workloads with a specific pool of resources . Identify and set priorities for workloads The current release of Resource Governor has the following limitations: . Resource allocation is only for CPU and memory usage. There is no support for managing network and disk I/O resource utilization. . Resource Governor manages only resource consumption of the Database Engine. You cannot use Resource Governor to manage workloads within SSAS, SSIS, or SSRS. In the following sections, you learn how to set up and configure Resource Governor for use, how Resource Governor works under the hood, and how you can use Resource Governor to better prioritize and manage a SQL Server’s workload. Resource Governor Components Resource Governor consists of three main components: classification, workload groups, and resource pools. Understanding these three components and how they interact is important to understanding and using Resource Governor. Classification Classification is the process of evaluating incoming user connections and assigning them to a workload group. Classification is performed by logic contained in a user-defined func- tion. The function returns the workload group name, which Resource Governor uses to route the sessions into the appropriate workload groups. 40 ptg 1496 CHAPTER 40 Managing Workloads with the Resource Governor When Resource Governor is configured, the login process for a session consists of the following steps: 1. Login authentication 2. LOGON trigger execution 3. Classification Workload Groups Workload groups are the containers for similar connections, which are grouped together as similar according to the classification criteria applied to each connection. A workload group also provides the mechanism for aggregate monitoring of resource consumption. Resource Governor has two predefined workload groups: the internal group and default group. The internal workload group is used solely by internal Database Engine processes. You cannot change the classification criteria for the internal group, and you also cannot classify any user requests for assignment to the internal group. You can, however, monitor the internal group. Connection requests are automatically classified into the default group when the follow- ing conditions exist: . There are no criteria to classify a request. . There is an attempt to classify the request into a nonexistent group. . There is a general classification failure. Resource governor supports a total of 20 workload groups. Because two of them are reserved for the internal and default workload groups, a total of 18 user-defined workload groups can be defined. Resource Pools A resource pool, or pool, represents the allocation of physical resources of the SQL Server. A resource pool has two parts: . The first part specifies the minimum resource reservation. This part of the resource pool does not overlap with other pools. . The other part specifies the maximum possible resource reservation for the pool. The resource allocation is shared with other pools. In SQL Server 2008 and SQL Server 2008 R2, the pool resources are set by specifying a MIN or MAX allocation for CPU and a MIN or MAX allocation for memory. The MIN setting specifies the minimum guaranteed resource availability of the pool. The MAX setting sets the maximum size of the pool for each of the resources. Because there cannot be any overlap in the minimum resource reservation, the sum of the MIN values across all pools cannot exceed 100% of the total server resources. The ensures that each pool is guaranteed the specified resource allocation. ptg 1497 Resource Governor Components The MAX value can be set anywhere in the range between the MIN value and 100% inclu- sive. The MAX setting represents the maximum amount of resources a session can consume, as long as the resources are available and not in use by another pool that is configured with a nonzero MIN value. When a pool has a nonzero MIN percentage defined, the effec- tive MAX value of other pools is readjusted down, as necessary, to the existing MAX value minus the sum total of the MIN values of other pools. For example, consider you have two user-defined pools. One pool, Pool1, is defined with a MIN setting of 20% and a MAX setting of 100%. The other pool, Pool2, is defined with a MIN setting of 50% and a MAX setting of 70%. The resulting effective MAX setting for Pool1 is 50% (100% minus the MIN 50% of Pool2). The effective MAX setting of Pool2, however, remains at 70% rather than 80% because 70% is the configured MAX value of Pool2. The shared part of the pool (the amount between the MIN and effective MAX values) is used to determine the amount of resources that can be consumed by the pool if the resources are available and not being consumed by another pool. When resources are consumed by a pool, they are assigned to the specified pool and are not shared until processing completes in that pool. To illustrate this further, consider a scenario in which there are three user-defined resource pools: . PoolA is defined with a MIN % of 10 and MAX % of 100. . PoolB is defined with a MIN % of 35 and a MAX % of 90. . PoolC is defined with a MIN % of 30 and a MAX % of 80. The effective MAX of PoolA would be calculated as follows: MAX % of PoolA 100 minus MIN % of PoolB 35 minus MIN % of PoolC 30 equals EFF MAX of PoolA 35 The total Shared % of resources of PoolA would then be calculated as follows: Effective MAX % of PoolA 35 minus MIN % of PoolA 10 equals Shared % of PoolA 25 Table 40.1 illustrates the calculated effective MAX and Shared % values for all pools in this configuration. 40 ptg 1498 CHAPTER 40 Managing Workloads with the Resource Governor To coincide with the predefined workload groups, Resource Governor also has two prede- fined resource pools: the internal pool and default pool. The internal pool represents the resources consumed by the internal processes of the Database Engine. This pool always contains only the internal group, and the pool is not alterable in any way. The Internal Pool has a fixed MIN % of 0 and a MAX % of 100, and resource consumption by the internal pool is not restricted or reduced by any settings in other pools. In other words, the effective MAX of the Internal Pool is always 100%. Any workloads in the internal pool are considered critical for server function, and Resource Governor allows the internal pool to consume 100% of available resources if necessary, even if it means the violation of the resource requirements of the other pools. The default pool is the first predefined user pool. Prior to any configuration, the default pool contains only the default group. The default pool cannot be created or dropped, but it can be altered. The default pool can contain user-defined groups in addition to the default group. Now that you have an understanding of the Resource Governor components, let’s put them into use by enabling and setting up some resource groups. Configuring Resource Governor To begin using Resource Governor for managing the resources of your workloads, follow these steps: 1. Enable Resource Governor. 2. Create your user-defined resource pools. 3. Define your workload groups and assign them to pools. 4. Create the classifier function. 5. Register the classifier function with the Resource Governor. NOTE Resource Governor can be set up and managed using either SQL Server Management Studio (SSMS) or via T-SQL commands. In the following sections, we first show you how to perform the tasks in SSMS and how the same actions can be implemented using T-SQL. TABLE 40-1 Effective MAX and Shared % Values for Multiple Pools ResourcePool MIN % MAX % Effective MAX % Shared % Internal 0 100 100 100 Default 0 100 25 25 PoolA 10 100 35 25 PoolB 35 90 50 15 PoolC 30 80 35 5 ptg 1499 Configuring Resource Governor FIGURE 40.2 Enabling Resource Governor in SSMS. Enabling Resource Governor Before you can begin creating your resource pools, you need to enable the Resource Governor first. To enable Resource Governor in SSMS, in Object Explorer, expand the Management node, right-click on the Resource Governor node, and select Enable (see Figure 40.2). 40 Alternatively, you can also enable Resource Governor by using the ALTER RESOURCE GOVERNOR command in T-SQL: ALTER RESOURCE GOVERNOR RECONFIGURE When Resource Governor is not enabled, the RECONFIGURE option enables Resource Governor. Enabling Resource Governor has the following results: . The classifier function, if defined, is executed for new connections so that their workload can be assigned to workload groups. . The resource limits specified in the Resource Governor configuration are honored and enforced. . Any connections that existed before Resource Governor was enabled are now affect- ed by any configuration changes made when Resource Governor was disabled. When Resource Governor is already enabled, the RECONFIGURE option must be executed to apply any configuration changes made using the CREATE|ALTER|DROP WORKLOAD GROUP or CREATE|ALTER|DROP RESOURCE POOL statements. ptg 1500 CHAPTER 40 Managing Workloads with the Resource Governor To determine whether Resource Governor is currently enabled, you can run a SELECT state- ment against the sys.resource_governor_configuration system catalog table to view the is_enabled column: select is_enabled from sys.resource_governor_configuration go is_enabled 1 To determine whether any RESOURCE GOVERNOR configuration changes are pending, you can use the sys.dm_resource_governor_configuration dynamic management view (DMV): select is_reconfiguration_pending from sys.dm_resource_governor_configuration go is_reconfiguration_pending 0 To disable Resource Governor, right-click on the Resource Governor node and select Disable or execute the following command in T-SQL: ALTER RESOURCE GOVERNOR DISABLE Defining Resource Pools When setting up a Resource Pool, you have to specify a name for the pool and set its properties. The properties available for a resource pool are . Name—The name used to refer to the resource pool . Minimum CPU %—The guaranteed average CPU bandwidth for all requests to the resource pool when there is CPU contention . Maximum CPU %—The maximum average CPU bandwidth for all requests to the resource pool when there is CPU contention . Min Memory %—The guaranteed minimum amount of memory reserved for the resource pool that cannot be shared with other resource pools . Max Memory %—The total server memory that can be used by requests to the resource pool Creating a Resource Pool in SSMS The following steps walk you through using SSMS to create a resource pool named ReportPool that you’ll configure for handling report query workloads: ptg 1501 Configuring Resource Governor 40 FIGURE 40.3 Creating a resource pool in SSMS. 1. In Object Explorer, expand the Management node for a SQL Server Instance and expand the Resource Governor node. 2. Right-click on Resource Pools and select New Resource Pool to open the Resource Governor Properties page (see Figure 40.3). 3. In the Resource Pools grid, click the first column in the empty row. This row is labeled with an asterisk (*). NOTE If the Resource Pools grid does not have a row labeled with an asterisk, Resource Governor has not been enabled yet. You can enable Resource Governor without leaving the Resource Governor Properties page by putting a check mark in the Enable Resource Governor check box. 4. Double-click the empty cell in the Name column. Type in the name that you want to use for the resource pool. For this example, use the name ReportPool. 5. Set the CPU and Memory resource values. In this example, leave the Min CPU % and Min Memory % values at 0 and configure the Max CPU % and Max Memory % values at 20 and 30, respectively. 6. To create the pool and exit the dialog, click OK. To verify that the new pool was created, you expand the Resource Pools folder under the Resource Governor node and look for a node named ReportPool. Alternatively, you can ptg 1502 CHAPTER 40 Managing Workloads with the Resource Governor run a query against the sys.resource_governor_resource_pools dynamic management view, similar to the following, which also displays the resource pool configuration: select name, min_cpu_percent as MinCPU, max_cpu_percent as MaxCPU, min_memory_percent as ‘MinMEM%’ , max_memory_percent as ‘MaxMEM%’ from sys.resource_governor_resource_pools go name MinCPU MaxCPU MinMEM% MaxMEM% internal 0 100 0 100 default 0 100 0 100 ReportPool 0 20 0 30 Creating a Resource Pool in T-SQL Now that you’ve set up the ReportPool resource pool in SSMS, you are able to set up a second resource pool, OLTPPool, using T-SQL. The command to create a resource pool, CREATE RESOURCE POOL, takes four arguments: MIN_CPU_PERCENT, MAX_CPU_PERCENT, MIN_MEMORY_PERCENT, and MAX_MEMORY_PERCENT. After creating the resource pool, you need to run ALTER RESOURCE GOVERNOR RECONFIGURE to apply the new resource pool: CREATE RESOURCE POOL OLTPPool WITH (min_cpu_percent=80, max_cpu_percent=100, min_memory_percent=75, max_memory_percent=100) GO ALTER RESOURCE GOVERNOR RECONFIGURE; GO Now that you’ve defined the resource pools needed, the next step is to define your work- load groups and associate them with a resource pool. Defining Workload Groups After you define your resource pools, the next step is to create the workload groups and associate them with the appropriate resource pools. Multiple workgroups can be assigned to that same pool, but a workgroup cannot be assigned to multiple resource pools. ptg 1503 Configuring Resource Governor 40 Creating Workload Groups in SSMS To create a workload group in SSMS, perform the following steps:. 1. In Object Explorer, expand the Management node, right-click the Resource Governor node, and then click Properties to bring up the Resource Governor Properties page. 2. In the Resource Pools grid, click the row for the resource pool you want to create a workload group for (in this example, the ReportPool resource pool). This creates a new empty row in the Workload Groups for Resource Pool grid for that pool. 3. Double-click the empty cell in the Name column for the empty workload group row and type in the name you want to use for the workload group (for this example, ReportWG1) and any other properties you want to specify (see Figure 40.4) 4. Click OK to exit the Properties page and create the workload group. The additional, optional properties available for workload groups let you set a finer level of control over the execution of queries within a workload group. The options available are . Importance—Specifies the relative importance ( LOW, MEDIUM, or HIGH) of the work- load group within the resource pool. If you define multiple workload groups in a FIGURE 40.4 Creating a Workload Group in SSMS. . Governor is available only in the Enterprise, Datacenter, and Developer Editions of SQL Server 2008 and SQL Server 2008 R2. Overview of Resource Governor Resource Governor works by controlling the allocation. reservation for the pool. The resource allocation is shared with other pools. In SQL Server 2008 and SQL Server 2008 R2, the pool resources are set by specifying a MIN or MAX allocation for CPU. associated with a resource pool. A resource pool represents the physical resources of SQL Server (currently in SQL Server 2008, the only physical resources available for configuration are CPU and memory)

Ngày đăng: 05/07/2014, 02:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN