CPU
In our sizing and production guidance, 1 vCPU is considered equivalent to 1 core in the underlying hardware platform.
CPU planning
Provision enough CPU to support your operational and workload concurrency requirements:CPU monitoring
Monitor possible signs of CPU starvation:Service latency
Degradation in SQL response time is the most common symptom of CPU starvation. It can also be a symptom of insufficient disk I/O.- The and graphs on the SQL dashboard show the time in nanoseconds between when the cluster . This time does not include returning results to the client.
- High CPU usage.
- An I/O bottleneck.
CPU usage
uses CPU to run concurrent worker threads.- The graph on the Hardware and Overload dashboards shows the CPU consumption by the CockroachDB process, and excludes other processes on the node. Expected values for a healthy cluster: CPU utilized by CockroachDB should not persistently exceed 80%. Because this metric does not reflect system CPU usage, values above 80% suggest that actual CPU utilization is nearing 100%.
COCKROACH_COMPACTION_CONCURRENCY environment variable. This may help to reshape the LSM more quickly in scenarios; and it can lead to increased overall performance for some workloads. Cockroach Labs strongly recommends testing your workload against non-default values of this setting.
Workload concurrency
The number of concurrent active SQL statements should be proportionate to your provisioned CPU.-
The graph on the Overview and SQL dashboards shows the 10-second moving average of
SELECT,UPDATE,INSERT, andDELETEstatements being executed per second on the cluster or node, as well asTotal queries. The latest QPS value for the cluster is also displayed with the Queries per second counter on the Metrics page. Expected values for a healthy cluster: At any time, the total number of connections actively executing SQL statements should not exceed 4 times the number of vCPUs in the cluster. You can find them in the Active Executions view in the or . You can find the number of open connections in the or . For more details on configuring connection pools, see .
- High CPU usage.
- Degradation in SQL response time.
- Over time, an unhealthy LSM and cluster instability.
LSM health
Issues at the storage layer, including an and high , can be observed when falls behind due to insufficient CPU or excessively high .- The graph on the Overload dashboard shows the health of the , which are implemented as log-structured merge (LSM) trees. Level 0 is the highest level of the LSM tree and consists of files containing the latest data written to the . For more information about LSM levels and how LSMs work, see . Expected values for a healthy cluster: An IO Overload value greater than 1.0 generally indicates an overload in the Pebble LSM tree. High values indicate heavy write load that is causing accumulation of files in level 0. These files are not being compacted quickly enough to lower levels, resulting in a .
An unhealthy LSM can be caused by other factors, including under-provisioned storage. To correlate this symptom with CPU starvation, check for high CPU usage and excessive workload concurrency.
- The Read Amplification graph on the shows the average number of disk reads per logical SQL statement, also known as the factor. Expected values for a healthy cluster: Read amplification factor should be in the single digits. A value exceeding 50 for 1 hour strongly suggests that the LSM tree has an unhealthy shape.
-
The
STORAGEindicates an unhealthy LSM with the following:- Frequent
compactionstatus messages. - High-read-amplification warnings, e.g.,
sstables (read amplification = 54).
- Frequent
COCKROACH_COMPACTION_CONCURRENCY environment variable. This may help to reshape the LSM more quickly in scenarios; and it can lead to increased overall performance for some workloads. Cockroach Labs strongly recommends testing your workload against non-default values of this setting.
Node health
If issues at the storage layer remain unresolved, affected nodes will eventually become unresponsive.- The on the Cluster Overview page indicates whether nodes are online (
LIVE) or have crashed (SUSPECTorDEAD). - The
/healthendpoint of the returns a500error when a node is unhealthy. - A can notify when a node has been down for 15 minutes or more.
If the cluster becomes unavailable, the DB Console and Cluster API will also become unavailable. You can continue to monitor the cluster via the and .
Memory
CockroachDB is to node crashes. However, frequent node restarts caused by can impact cluster stability and performance.Memory planning
Provision enough memory and allocate an appropriate portion for data caching:- Provision at least 4 GiB of RAM per vCPU.
- Disable Linux memory swapping. Over-allocating memory on production machines can lead to unexpected performance issues when pages have to be read back into memory.
-
The default value for
--cacheis 128 MiB. For production deployments, set--cacheto25%or higher. To determine appropriate settings for--cacheand--max-sql-memory, use the following formula:
--max-sql-memory.
Test the configuration with a reasonable workload before deploying it to production.
On startup, if CockroachDB detects that
--max-sql-memory or --cache are set too aggressively, a warning is logged.Memory monitoring
Monitor memory usage and node behavior for :Node process restarts
CockroachDB attempts to restart nodes after they crash. Nodes that frequently restart following an abrupt process exit may point to an underlying memory issue.- The on the Cluster Overview page indicates whether nodes are online (
LIVE) or have crashed (SUSPECTorDEAD). - When deploying on , the
kubectl get podsoutput contains aRESTARTScolumn that tracks the number of restarts for each CockroachDB pod. - The
OPSwill record a whenever a node rejoins the cluster after being offline. - A can notify when a node has restarted more than once in the last 10 minutes.
Verify OOM errors
If you observe nodes frequently restarting, confirm that the crashes are caused by :-
Monitor
dmesgto determine if a node crashed because it ran out of memory:The following output indicates the node crashed due to insufficient memory: -
When deploying on , run
kubectl logs {pod-name}and look for OOM errors in the log messages.
SQL memory usage
An untuned SQL query can consume significant resources and impact the performance of other workloads.-
The graph on the SQL dashboard shows the current amount of memory in KiB allocated to the SQL layer.
Expected values for a healthy cluster: This value should not exceed the size. A healthy threshold is 75% of allocated
--max-sql-memory. -
The “active query dump”, enabled by default with the
diagnostics.active_query_dumps.enabled, is a record of anonymized active queries that is written to disk when a node is detected to be under memory pressure. You can use the active query dump to correlate specific queries to OOM crashes. Active query dumps have the filenameactivequeryprof.{date-and-time}.csvand are found in theheap_profilerdirectory in the configured . They are also included when running . -
A
SHOW STATEMENTSstatement can on the cluster that may be consuming excessive memory. -
A error in the logs indicates that
--max-sql-memory, the memory allocated to the SQL layer, was exceeded by the operation referenced in the error. For guidance on resolving this issue, see .
Database memory usage
CockroachDB memory usage includes both accounted memory, such as the amount allocated to--cache and --max-sql-memory; and unaccounted memory, such as uncollected Go garbage and process overhead.
- The graph on the Runtime dashboard shows the total memory in use by CockroachDB processes. The RSS (resident set size) metric represents actual CockroachDB memory usage from the OS/Linux/pod point of view. The Go and CGo metrics represent memory allocation and total usage from a CockroachDB point of view. Expected values for a healthy cluster: Go Allocated will depend on workload but should not exceed by more than 100%. CGo Allocated should not exceed the size and CGo Total should not exceed the size by more than 15%.
Storage and disk I/O
The cluster will underperform if storage is not provisioned or configured correctly. This can lead to further issues such as and node shutdown.Storage and disk planning
Provision enough storage capacity for CockroachDB data, and configure your volumes to maximize disk I/O:Storage and disk monitoring
Monitor storage capacity and disk performance:Storage capacity
CockroachDB requires disk space in order to accept writes. When a node runs out of disk space, it shuts down and cannot be restarted until space is freed up.- The graph on the Overview and Storage dashboards shows the available and used disk capacity in the CockroachDB . Expected values for a healthy cluster: Used capacity should not persistently exceed 80% of the total capacity.
- A can notify when a node has less than 15% of free space remaining.
Disk IOPS
Insufficient disk I/O can cause poor SQL performance and potentially .- The graph on the Hardware dashboard shows the number of disk reads and writes in queue. Expected values for a healthy cluster: This value should be 0 or single-digit values for short periods of time. If the values persist in double digits, you may have an I/O bottleneck.
-
The Linux tool
iostat(part ofsysstat) can be used to monitor IOPS. In the device status output,avgqu-szcorresponds to the Disk Ops In Progress metric. If service times persist in double digits on any node, this means that your storage device is saturated and is likely under-provisioned or misconfigured.
- Degradation in SQL response time.
- An unhealthy LSM.
Node heartbeat latency
- The and graphs on the show the time elapsed between node heartbeats. Expected values for a healthy cluster: Less than 100ms in addition to the between nodes in the cluster.
- Whether a node is still a member of a cluster (this is used by ).
- Whether a node is dead (in which case ).
- How to avoid placing replicas on dead, decommissioning or unhealthy nodes, and to make decisions about lease transfers.
Command commit latency
- The Command Commit Latency: 50th percentile and Command Commit Latency: 99th percentile graphs on the show how quickly are being committed by nodes in the cluster. This is a good signal of I/O load. Expected values for a healthy cluster: On SSDs (), this should be between 1 and 100 milliseconds. On HDDs, this should be no more than 1 second.
See also
- (CockroachDB Advanced)

