Open-Source Wikis

/

CockroachDB

/

Features

/

Admission control

cockroachdb/cockroach

Admission control

CockroachDB's admission control engine (pkg/util/admission/) regulates CPU, store IO, and Raft replication traffic to keep latency stable under overload. KV server and SQL surface integrate with it through pkg/kv/kvserver/kvadmission/ and pkg/kv/kvserver/kvflowcontrol/.

What it does

Without admission control, a CockroachDB node will accept work until queues blow up and tail latency collapses. The admission engine introduces priority queues at three points:

  • CPUpkg/util/admission/work_queue.go. SQL statements, KV requests, and background work are graded by priority and admitted only when CPU runnable count is below a threshold.
  • Store IOpkg/util/admission/io_load_listener.go. Watches Pebble L0 sublevels and outstanding bytes; if the LSM is "overloaded", the queue admits less.
  • Raft flow controlpkg/kv/kvserver/kvflowcontrol/. Limits in-flight Raft proposals per (range, follower) so a slow follower can't exhaust memory on the leader.

Priorities

Defined in pkg/util/admission/admissionpb/. From highest to lowest: LockingNormalPri, NormalPri, LowPri, BulkNormalPri, BulkLowPri. Backups, schema-change backfill, IMPORT, and consistency checks run at lower priorities so they yield to user traffic.

Wire-up

  • SQL: pkg/sql/conn_executor.go admits before execution.
  • KV: pkg/kv/kvserver/kvadmission/kvadmission.go admits each BatchRequest.
  • Replication: pkg/kv/kvserver/kvflowcontrol/ regulates Raft sends.

Tests and simulators

pkg/util/admission/admissiontest/ and Pebble's own admission simulator reproduce overload scenarios deterministically. The roachtest suite includes severe-overload scenarios (e.g., tpcc-severe-overload) that gate this code.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Admission control – CockroachDB wiki | Factory