Company
Date Published
Author
Raphael Kena Poss
Word count
3810
Language
English
Hacker News points
None

Summary

CockroachDB, a distributed SQL database built on RocksDB, manages memory usage across its nodes by allocating memory to various components, with the largest portion dedicated to the RocksDB cache, followed by memory used at rest for replica metadata and activity-related memory for store processing and SQL operations. Memory allocation is influenced by factors like the number of nodes, replication factor, and node speed, which can be monitored using CockroachDB's admin UI to observe metrics such as the number of SQL clients and queries. The database's memory usage strategies include predictable patterns for at-rest memory and less predictable trends for activity-based memory, with adjustments made through parameters like the number of stores or nodes. CockroachDB has introduced measures to prevent memory overload from SQL operations by implementing a soft limit, defaulting to 25% of total system memory, to guard against accidental client-side errors. While some memory allocations are tracked precisely, others, particularly those related to the managed Go runtime, remain less visible, leading to ongoing efforts to better quantify and manage these overheads.