Blog
AdvancedReferenceProduction Operations

CPU, memory, and resource governance

The shared-resource knobs - MAXDOP and cost threshold for parallelism, max server memory and the buffer pool, Resource Governor workloads, and the waits that tell you which resource is actually binding.

Applies to
SQL Server2016-2025 (13.x-17.x)
matureUpdated Reviewed
advancedAssumes production experience with the basics.

What you will be able to do

  • Set MAXDOP and cost threshold for parallelism from the workload and NUMA layout, not a blog number.
  • Bound max server memory correctly so the OS is not starved, and read buffer hit ratio honestly.
  • Read the parallelism waits - CXPACKET vs CXCONSUMER - and tell a parallelism problem from a scan problem.
  • Use Resource Governor to cap a noisy workload without touching the rest.

An instance has a finite supply of three things: CPU schedulers, buffer-pool memory, and I/O bandwidth. Governance is deciding who gets how much when the supply runs out - and the honest starting point is the waits, because the right knob is always the resource the waits name.

The analogy is a block of flats on one electricity supply, one boiler, and one water main. Letting a single tenant’s event plug into every circuit at once is MAXDOP of zero - the party runs at full power while every other flat browns out. Reserving part of the boiler’s output for the building’s own systems is the headroom max server memory must leave the operating system. And the concierge who allocates each flat a guaranteed share and a cap is Resource Governor - deciding who gets how much only matters once the supply runs short.

MAXDOP and cost threshold for parallelism

Two settings decide when a query goes parallel and how far:

  • cost threshold for parallelism (default 5) - a plan goes parallel only if its estimated serial cost exceeds this. The default is decades old and far too low for modern hardware - a common guidance value is 50, set deliberately against your own plans, not cargo-culted.
  • max degree of parallelism (default 0) - 0 means “use all cores,” which lets one big parallel query claim every scheduler and starve concurrent work. On a NUMA box the guidance is to cap at the number of cores per NUMA node (commonly 8), so parallelism does not cross nodes and leave the rest of the workload queueing.

The waits tell you which problem you have:

Wait Means Usually
CXPACKET A parallel worker waits at the operator exchange Coarse signal - on its own it often just means “queries ran in parallel,” not that parallelism is wrong
CXCONSUMER The coordinator waits on a slow producer thread Added in 2016 SP2 / 2017 CU3 to split the real signal out of CXPACKET - a skewed parallel plan, one thread doing the work
SOS_SCHEDULER_YIELD Runnable tasks queue for a scheduler Genuine CPU pressure - the box is out of cores, or one workload is eating them

High CXCONSUMER with low CPU = a parallelism problem (skewed plan or too-high DOP). High SOS_SCHEDULER_YIELD with CPU pinned = the box is out of cores, and no MAXDOP setting adds cores. The mistake is reaching for MAXDOP = 1 to silence CXPACKET - it serialises the big queries and makes them slower, trading the symptom for a worse one.

Memory - the buffer pool and its honest limits

SQL Server’s memory is dominated by the buffer pool (the data-page cache), with plan cache, memory grants, and lock structures sharing the rest. The one setting that matters most:

  • max server memory - set it, and leave headroom. Default is effectively “all of it,” which lets the buffer pool grow until the OS is starved and starts paging - a far worse outcome than a smaller pool. Leave the OS, the thread stacks, and any other process on the box real headroom; on a dedicated server the remainder after a sensible reservation goes to the buffer pool.

Read buffer pool hit ratio honestly: a low ratio means the working set exceeds memory - physical reads dominate and PAGEIOLATCH is the wait. But a high ratio does not prove health; it just says the cache is warm. A workload can have a perfect hit ratio and still queue on CPU or locks, because memory was never the binding resource.

Resource Governor - the circuit breaker for a noisy workload

When one workload - a report, a maintenance job, a misbehaving app - must not take the whole box, Resource Governor partitions the scheduler and memory supply. You define workload groups matching sessions by classifier (login, app name), and resource pools capping CPU and memory per group.

Contain one workload without touching the rest

  1. Classify

    A classifier function maps each session to a workload group

    By login, app name, host - decide at connection time

  2. Group

    Sessions land in workload groups

    A report group, an OLTP group, a default group

  3. Cap

    Each group runs in a resource pool with CPU/memory limits

    MIN guarantees, MAX caps - the report cannot starve OLTP

  4. Govern

    The noisy workload is contained at a ceiling

    It runs slower; everything else keeps its share

The classifier routes each session into a group; the pool caps what that group can take. The other groups keep their fair share.

Resource Governor caps contended resources - it does not make a slow query fast, it makes a fat query unable to eat everything. It is an Enterprise/edition feature and the right tool for mixed workloads on one instance; on dedicated single-workload boxes it usually adds complexity with no contention to govern.

The discipline

The settings are few and the temptation is to copy values. The sequence is always: read the wait profile, name the binding resource, then set the knob that addresses that resource - SOS_ SCHEDULER_YIELD says cores, PAGEIOLATCH says memory-or-storage, CXCONSUMER says the parallel plan, and Resource Governor says “two workloads that must not share.” A knob set against a wait it does not address is tuning by superstition.

Guided practice

A diagnostic exercise: you are handed three wait profiles from a mixed OLTP-and-reporting instance, then one governance problem. For each, name the binding resource and the knob that addresses it - and only that knob. Work each step and check yourself before moving on.

  1. Profile A: high SOS_SCHEDULER_YIELD, CPU pinned at the ceiling. Name the binding resource and the honest fix. Check: CPU - the box is out of cores, or one workload is eating them. No MAXDOP setting adds cores; the fix is finding which workload consumes the schedulers. If you answered “lower MAXDOP”, revisit the waits table - SOS_SCHEDULER_YIELD is genuine CPU pressure, not a parallelism fault.
  2. Profile B: high CXCONSUMER, CPU low. Parallelism problem or core shortage? Check: a parallelism problem - a skewed plan or a too-high degree of parallelism, with one thread doing the work while the coordinator waits. CXCONSUMER was added in SQL Server 2016 SP2 and 2017 CU3 to split exactly this signal out of CXPACKET; if you read it as a core shortage, revisit the waits table.
  3. Profile C: PAGEIOLATCH dominates and the buffer hit ratio is low. What is starving? Check: memory-or-storage - the working set exceeds the buffer pool, so physical reads dominate. The knob is max server memory set with real headroom for the OS - not the effective “all of it” default that grows the pool until the operating system pages. If you treated the low ratio itself as the diagnosis, revisit the memory section - it says the cache is cold, not why.
  4. A nightly report starves the OLTP path. Which tool, and what does it change? Check: Resource Governor - a classifier maps the report’s sessions to a workload group, the group lands in a resource pool with CPU and memory caps (MIN guarantees, MAX caps), and the report runs slower inside its ceiling while everything else keeps its share. It caps contended resources; it does not make the report fast. If you proposed a MAXDOP change, revisit the Governor diagram - containment is a different tool than tuning.
  5. State the discipline in one sentence. Before any knob is touched. Check: read the wait profile, name the binding resource, then set the knob that addresses that resource - SOS_SCHEDULER_YIELD says cores, PAGEIOLATCH says memory-or-storage, CXCONSUMER says the parallel plan, and Resource Governor says “two workloads that must not share”. If your sentence starts with a setting, revisit the discipline - a knob set against a wait it does not address is tuning by superstition.

Check your understanding

Ordered easy to hard. Answer each before reading the answer; a wrong answer names where to look.

  1. What are the three finite resources an instance has to divide? CPU schedulers, buffer-pool memory and I/O bandwidth - governance is deciding who gets how much when the supply runs out, and the waits name which supply ran out.
  2. What do cost threshold for parallelism and MAXDOP each control? The threshold decides when a plan may go parallel - its estimated serial cost must exceed it, and the default of 5 is far too low for modern hardware - while MAXDOP decides how far, and its default of 0 lets one big query claim every scheduler. If you conflated them, revisit the first section - one gates the decision, the other bounds the fan-out.
  3. What does CXCONSUMER tell you that CXPACKET does not? CXPACKET alone often just means queries ran in parallel; CXCONSUMER, added in 2016 SP2 / 2017 CU3 to split the real signal out, means the coordinator waits on a slow producer thread - a skewed parallel plan with one thread doing the work. If you read CXPACKET alone as a fault, revisit the waits table.
  4. Why is the max server memory default dangerous, and why does a high buffer hit ratio not prove health? The default is effectively “all of it” - the pool grows until the OS is starved and starts paging, a worse outcome than a smaller pool. A high ratio only says the cache is warm: the workload can still queue on CPU or locks because memory was never the binding resource. If you cited the ratio as proof of health, revisit the memory section.
  5. Why does MAXDOP = 1 fail as a fix for CXPACKET, and what does Resource Governor do instead of fixing the query? MAXDOP = 1 serialises the big queries and makes them slower - it trades the symptom for a worse one. Governor caps contended resources so a fat query cannot eat everything: the noisy workload runs slower inside its ceiling while the rest keep their share. If you expected either to make the slow query faster, revisit the mistake note and the Govern stage - containment is not a performance fix.

Where SQL Server sits

How this component relates to the rest of the stack. Items without a link are not covered here yet.

Deployed with

Commonly run alongside

  • Windows Failover Clustering

Alternatives

Solves a similar problem differently