Skip to main content
This page summarizes how to configure and monitor your cluster to prevent issues commonly encountered with:

CPU

In our sizing and production guidance, 1 vCPU is considered equivalent to 1 core in the underlying hardware platform.
Issues with CPU most commonly arise when there is insufficient CPU to support the scale of the workload.

CPU planning

Provision enough CPU to support your operational and workload concurrency requirements:
CategoryRecommendations
CPU
  • For cluster stability, Cockroach Labs recommends a minimum of 8 vCPUs, and strongly recommends no fewer than 4 vCPUs per node. In a cluster with too few CPU resources, foreground client workloads will compete with the cluster’s background maintenance tasks.
  • Cockroach Labs does not extensively test clusters with more than 64 vCPUs per node. This is the recommended maximum threshold.
  • Use larger VMs to handle temporary workload spikes and processing .
  • Use connection pooling to manage workload concurrency. The number of active connections across all connection pools should not exceed 4 times the number of vCPUs in the cluster by a large amount. A connection is “active” when it is actively executing a query. To monitor active connections, use the . For more details, refer to .
  • For additional CPU recommendations, refer to .

CPU monitoring

Monitor possible signs of CPU starvation:
ParameterDescription
Service latencyThe time between when the cluster receives a query and finishes executing the query.
CPU usageThe CPU consumption by the CockroachDB node process.
Workload concurrencyThe number of SQL statements being executed on the cluster at the same time.
LSM healthThe health of the persistent stores.
Node healthThe operational status of the nodes.

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.
If latencies are consistently high, check for:

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%.
If CPU usage is high, check whether workload concurrency is exceeding CPU resources. By default, the uses a compaction concurrency of 3. If you have sufficient IOPS and CPU headroom, you can consider increasing this setting via the 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, and DELETE statements being executed per second on the cluster or node, as well as Total 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 .
If workload concurrency exceeds CPU resources, you will observe: To prevent issues with workload concurrency, and use for the workload.

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 STORAGE indicates an unhealthy LSM with the following:
    • Frequent compaction status messages.
    • High-read-amplification warnings, e.g., sstables (read amplification = 54).
If compaction has fallen behind and caused an , throttle your workload concurrency to allow to catch up and restore a healthy LSM shape. The number of active connections across all connection pools should not exceed 4 times the number of vCPUs in the cluster by a large amount. A connection is “active” when it is actively executing a query. To monitor active connections, use the . If a node is severely impacted, you can and then . By default, the uses a compaction concurrency of 3. If you have sufficient IOPS and CPU headroom, you can consider increasing this setting via the 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 (SUSPECT or DEAD).
  • The /health endpoint of the returns a 500 error when a node is unhealthy.
  • A can notify when a node has been down for 15 minutes or more.
If nodes have shut down, this can also be caused by insufficient storage capacity.
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 --cache is 128 MiB. For production deployments, set --cache to 25% or higher. To determine appropriate settings for --cache and --max-sql-memory, use the following formula:
To help guard against , CockroachDB sets a soft memory limit using mechanisms in Go. Depending on your hardware and workload, you may not need to manually tune --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.
For additional memory recommendations, refer to and .

Memory monitoring

Monitor memory usage and node behavior for :
Metric or eventDescription
Node process restartsNodes restarting after crashes
SQL memory usageThe memory allocated to the SQL layer
Database memory usageThe memory in use by CockroachDB processes

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 (SUSPECT or DEAD).
  • When deploying on , the kubectl get pods output contains a RESTARTS column that tracks the number of restarts for each CockroachDB pod.
  • The OPS will 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 dmesg to 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.
To prevent OOM crashes, . If all CockroachDB machines are provisioned and configured correctly, either run the CockroachDB process on another node with sufficient memory, or . If you confirm that nodes are crashing due to OOM errors, also check whether SQL queries may be responsible.

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 filename activequeryprof.{date-and-time}.csv and are found in the heap_profiler directory in the configured . They are also included when running .
  • A SHOW STATEMENTS statement 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 .
If you find queries that are consuming too much memory, to free up memory usage. For information on optimizing query performance, see . We strongly recommend adding size limits to all , which includes columns in . Values exceeding 1 MiB can lead to and cause significant performance degradation or even . To add a size limit using :
To add a size limit using :

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%.
For more context on acceptable memory usage, see .

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:
CategoryRecommendations
Storage- Provision volumes with 320 GiB per vCPU. - Use dedicated volumes for the CockroachDB . Do not share the store volume with any other I/O activity. - Determine where CockroachDB will be stored: either on the same volume as the main data store or on a separate volume from the main data store. Refer to in Logging Best Practices. - See additional storage recommendations in the .
Disk I/O- Disks must be able to achieve 500 IOPS and 30 MB/s per vCPU . - Do not use LVM in the I/O path. Dynamically resizing CockroachDB store volumes can result in significant performance degradation. Using LVM snapshots in lieu of CockroachDB is also not supported. Use instead. - See additional disk I/O recommendations in the .

Storage and disk monitoring

Monitor storage capacity and disk performance:
Metric or eventDescription
Storage capacityThe available and used disk capacity in the CockroachDB .
Disk IOPSThe I/O requests per second.
Node heartbeat latencyThe time between heartbeats.
Command commit latencyThe speed at which are being committed by nodes in the cluster.

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.
Ensure that you . If storage is correctly provisioned and is running low, CockroachDB automatically creates an emergency ballast file that can free up space. For details, see .
For instructions on how to free up disk space as quickly as possible after dropping a table, see

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 of sysstat) can be used to monitor IOPS. In the device status output, avgqu-sz corresponds 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.
With insufficient disk I/O, you may also see:

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.
For the purposes of and determining the of a , node health is no longer determined by heartbeating a single “liveness range”; instead it is determined using . However, node heartbeats of a single range are still used to determine:
  • 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)