Resource Guvenor advice

  • All,

    I'm planning on settingup a set of resource pools as we planning on consolidating servers and developers being developers they comlpain about other peopl taking 'thier' resources.

    So we decided to go down the route of setting up Resource pools for each application to stop the arguments between the teams.

    Im working through the MS white paper "Using The Resource Governor" and its associated documents, and the example in Kalen Delaney's SQL Server 2008 Internals.

    Any tips, hints or other advice about setting these up and more importantly testing them before we switch over the apps etc.

    all help greatly appreciated.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • I'd imagine these are covered by the documentation you're reading, but a few things:

    Make sure your classifier function is as lightweight as possible - every connection to SQL server has to run it before it can connect.

    If using program_name in the classifier, be aware it can be easily spoofed, and of variations within the name for the same program.

    For testing:

    You can use GroupId in sys.dm_exec_requests & sys.dm_exec_sessions to find which workload group & resource pool the query is running in.

    Perfmon counters in these groups can help you monitor resource governor effects:

    MSSQL$InstanceName:Workload Group Stats & MSSQL$InstanceName: Resource Pool Stats

    RG is not instance-aware, and only works on the database engine itself.

    Note that RG is only really a guide, limits can be exceeded if the server is not under load.

  • Thanks Gaz, I've been through the documentation, a couple of times, this is the first real implementation, were planning on using the App_name in order to seperate the different projects as all connection strings should pass that to the database.

    We're running SQL Server Build 10.0.5500 on a 32 core (hyper-t to 64) with 256GB of ram.

    One thing I have noticed is that even though I set up a MAX_DOP=2 in the Workload Group set up, when the query runs it the server seems to override this and use more of the processors.

    Yet when I reset the MAX_DOP=1 it runs as expected on a single processor,is this a known issue with the resource guvernor or have i missed something simple?

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • Hi Jason,

    AKAIK it should respect the RG setting - where are you seeing the additional usage (e.g.perfmon/DMV's/Task Manager/ShowPlans)?

    Thanks

    Gaz

  • Mainly Task manager, though also resource manager.

    This is the set up (using a template from SSMS)

    -- ================================================

    -- Template generated from Template Explorer using:

    -- Configure Resource Governor.sql

    --

    -- Use the Specify Values for Template Parameters

    -- command (Ctrl-Shift-M) to fill in the parameter

    -- values below.

    --

    -- This template creates "admin" workload group

    -- which uses "admin" resource pool and creates

    -- corresponding classifier function which puts

    -- sysadmins in such group

    -- ================================================

    -- Classifier functions for the Resource Governor must

    -- reside within the master database.

    USE [master]

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    -- Create resource pool to be used

    CREATE RESOURCE POOL [PoolApps]

    WITH (

    -- allocate at least <MIN_CPU_PERCENT, int, 10>% of the CPU bandwidth for admin queries

    MIN_CPU_PERCENT = 10

    -- do not let them exceed <MAX_CPU_PERCENT, int, 30>% either

    , MAX_CPU_PERCENT = 20

    -- admin queries should be small and we will allocate about <MIN_MEMORY_PERCENT, int, 5>%

    -- of the server memory for them

    , MIN_MEMORY_PERCENT = 10

    , MAX_MEMORY_PERCENT = 30

    )

    GO

    -- TODO

    -- Create additional resource pools here

    -- Create admin workload group

    CREATE WORKLOAD GROUP [AdHoc]

    WITH (

    -- use all defaults

    IMPORTANCE = MEDIUM

    , REQUEST_MAX_MEMORY_GRANT_PERCENT = 25

    , REQUEST_MEMORY_GRANT_TIMEOUT_SEC = 0

    , REQUEST_MAX_CPU_TIME_SEC = 1

    , MAX_DOP = 2

    , GROUP_MAX_REQUESTS = 0

    )

    USING

    [PoolApps]

    GO

    -- TODO

    -- Create additional workload groups here

    -- Set the classifier function for Resource Governor

    ALTER RESOURCE GOVERNOR

    WITH (

    CLASSIFIER_FUNCTION = null

    )

    GO

    ALTER RESOURCE GOVERNOR RECONFIGURE

    GO

    ALTER FUNCTION dbo.fn_classifier()

    RETURNS sysname

    WITH SCHEMABINDING

    AS

    BEGIN

    -- Define the return sysname variable for the function

    DECLARE @grp_name AS sysname

    ,@app_name as sysname;

    SET @grp_name = 'default';

    Set @app_name=Lower(APP_NAME());

    -- Specify the T-SQL statements for mapping session information

    -- with Workload Groups defined for the Resource Governor.

    Select @grp_name=

    CASE

    WHEN @app_name like '%management studio%'

    or @app_name in ('sql query analyzer','ms sqlem')

    Then 'AdHoc'

    Else 'default'

    END

    -- TODO

    -- Put additional classification logic here

    RETURN @grp_name;

    END

    GO

    -- Set the classifier function for Resource Governor

    ALTER RESOURCE GOVERNOR

    WITH (

    CLASSIFIER_FUNCTION = dbo.fn_classifier

    )

    GO

    -- Make changes effective

    ALTER RESOURCE GOVERNOR RECONFIGURE

    GO

    ALTER RESOURCE GOVERNOR RESET STATISTICS

    GO

    When 'playing around' with the maxdop I usually do this through the GUI, and issue a RECONFIGURE and RESET STATS.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • Hi Jason,

    Looks fine to me.

    Is this for multiple queries? The MAX_DOP setting in CREATE WORKLOAD GROUP should prevent individual queries running on more than 2 processors, but multiple queries don't have to run on the same set of 2 processors.

    In contrast, the MAX_CPU_PERCENT option in CREATE RESOURCE POOL will limit the entire pool to 20% CPU, but only in the case of CPU use pressure.

    I think the number of CPU's affects how close you can get to the limit as well - e.g. imagine trying to limit to 30% on a 2-CPU dual core system.

    There will likely be other processes going on that fall into the internal pool too.

    It's been a while since I've used it - does Task Manager or Resource Manager give you a breakdown by Resource Pool or Workload Group?

    Cheers

  • Thanks for the response Gaz, and the advice, at the moment I'm just doing a proof of concept and getting used to how to configure the resource governor, ready for when we commission the new server.

    As far as I'm aware they dont, I suppose I'll have to use PrefMon for that kind of information resource monitor

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • No problem mate, hope it goes well!

    Cheers

    Gaz

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply