How admission control works
At a high level, the admission control system works by queueing requests to use the following system resources:- CPU
- Storage IO (writes to disk)
Use cases for admission control
A well-provisioned CockroachDB cluster may still encounter performance bottlenecks at the node level, as stateful nodes can develop that last until the cluster rebalances itself. When hotspots occur, they should not cause failures or degraded performance for important work. This is particularly important for CockroachDB Standard and CockroachDB Basic, where one user tenant cluster experiencing high load should not degrade the performance or availability of a different, isolated tenant cluster running on the same host. Admission control can help if your cluster has degraded performance due to the following types of node overload scenarios:- The node has more than 32 runnable goroutines per CPU, visible in the Runnable goroutines per CPU graph in the .
- The node has a high amount of overload in the Pebble LSM tree, visible in the IO Overload graph in the .
- The node has high CPU usage, visible in the CPU Utilization graph in the .
- The node is experiencing out-of-memory errors, visible in the Memory Usage graph in the . Even though admission control does not explicitly target controlling memory usage, it can reduce memory usage as a side effect of delaying the start of operation execution when the CPU is overloaded.
Operations subject to admission control
Almost all database operations that use CPU or perform storage IO are controlled by the admission control system. From a user’s perspective, specific operations that are affected by admission control include:- have their CPU usage subject to admission control, as well as storage IO for writes to and follower replicas.
- .
- statements.
- (including deletes initiated by ; the performed by TTL jobs are also subject to CPU admission control).
- .
- operations, including , , and restores.
- , including index and column backfills (on both the and ).
- Follower replication work.
- .
- .
- .
Admission control is beneficial when overall cluster health is good but some nodes are experiencing overload. If you see these overload scenarios on many nodes in the cluster, that typically means the cluster needs more resources.
Replication admission control
The admission control subsystem paces all work done at the to avoid cluster overload. This includes user-facing writes from SQL statements, as well as background (elastic) replication work. The pacing of catchup writes is controlled at the replication layer to avoid overloading slow or with replication flows. Note that this pacing does not slow down user-facing SQL writes; it only ensures there are fewer impacts from background operations. At a high level, replication admission control works by:- Pacing regular SQL writes at the rate of replica quorum. ()
- Pacing background (elastic) replication at the rate of the slowest replica.
- Does not overload slow/restarted nodes with replication flows. ()
- Isolates performance between regular and elastic traffic.
- Paces regular writes at quorum speed. ()
- Paces elastic writes at the slowest replica’s speed.
Enable and disable admission control
Admission control is enabled by default. To enable or disable admission control, use the following :admission.kv.enabledfor work performed by the .admission.sql_kv_response.enabledfor work performed in the SQL layer when receiving .admission.sql_sql_response.enabledfor work performed in the SQL layer when receiving .kvadmission.store.snapshot_ingest_bandwidth_control.enabledto optionally limit the disk impact of ingesting snapshots on a node. This cluster setting is in .kvadmission.store.provisioned_bandwidthto optionally limit the disk bandwidth capacity of stores on the cluster. Disk bandwidth admission control paces background disk writes to keep disk bandwidth within its provisioned bandwidth. This cluster setting is in .
Work queues and ordering
When admission control is enabled, request and response operations are sorted into work queues where the operations are organized by priority and transaction start time. Higher priority operations are processed first. The criteria for determining higher and lower priority operations is different at each processing layer, and is determined by the CPU and storage I/O of the operation. Write operations in the in particular are often the cause of performance bottlenecks, and admission control prevents from experiencing high . Critical cluster operations are processed as high priority, as are transactions that hold in order to avoid and release locks earlier. The transaction start time is used within the priority queue and gives preference to operations with earlier transaction start times. For example, within the high priority queue operations with an earlier transaction start time are processed first.Set quality of service level for a session
In an overload scenario where CockroachDB cannot service all requests, you can identify which requests should be prioritized. This is often referred to as quality of service (QoS). Admission control queues work throughout the system. To set the quality of service level on the admission control queues on behalf of SQL requests submitted in a session, use the session variable. The valid values arecritical, background, and regular. Admission control must be enabled for this setting to have an effect.
To increase the priority of subsequent SQL requests, run:
background.
To increase the priority of subsequent COPY statements, run:
Set quality of service level for a transaction
To set the quality of service level for a single , set the and/or session variable for just that transaction using the statement inside a … block, as shown in the following example. The valid values arecritical, background, and regular.
Known limitations
Admission control works on the level of each node, not at the cluster level. The admission control system queues requests until the operations are processed or the request exceeds the timeout value (for example by using ). If you specify aggressive timeout values, the system may operate correctly but have low throughput as the operations exceed the timeout value while only completing part of the work. There is no mechanism for preemptively rejecting requests when the work queues are long. Organizing operations by priority can mean that higher priority operations consume all the available resources while lower priority operations remain in the queue until the operation times out.Considerations
are not managed by the admission control subsystem. Too many connections per can also lead to cluster overload. To control the maximum number of non-superuser ( user or other ) connections a can have open at one time, use theserver.max_connections_per_gateway . If a new non-superuser connection would exceed this limit, the error message "sorry, too many clients already" is returned, along with error code 53300.
Observe admission control performance
The shows metrics related to the performance of the admission control system.See also
- The in the .
- The blog post Here’s how CockroachDB keeps your database from collapsing under load.
- The blog post Rubbing Control Theory on the Go scheduler.

