Home > Storage > PowerFlex > White Papers > CockroachDB Deployment on Dell PowerFlex with Kubernetes > CockroachDB architecture
The CockroachDB cluster is a group of interconnected CockroachDB nodes that functions as a single distributed SQL database server. Nodes collaboratively organize transactions, and rebalance workload and data storage, to optimize performance and fault-tolerance. A CockroachDB cluster can be run in CockroachDB cloud, within a customer organization, or can be self-hosted.
CockroachDB architecture is structured in layers that makes it easier to manage complexity. Each higher layer in the architecture treats the lower levels as functional black boxes, while the lower layers remain unaware of the higher ones.
The following figure shows the CockroachDB architecture:
Layers in the CockroachDB architecture:
CockroachDB stores all user data and almost all system data in a sorted map of key-value pairs. This keyspace is divided into contiguous chunks called ranges, such that every key is found in one range. From a SQL perspective, a table and its secondary indexes initially map to a single range, where each key-value pair in the range represents a single row in the table. When the size of a range reaches the default range size, it is split into two ranges. This process continues for these new ranges as the table and its indexes continue growing. CockroachDB implements a Raft consensus algorithm for consistency and aims to tolerate disk, machine, rack, and even data center failures with minimal disruption and no manual intervention.
When CockroachDB runs a query, the cluster routes the request to the leaseholder for the range containing the relevant data. The leaseholder is the replica that holds the "range lease." This replica receives and coordinates all read and write requests for the range. If the query touches multiple ranges, the request goes to multiple leaseholders.
For a read request, only the leaseholder of the relevant range retrieves the data. For a write request, the Raft consensus protocol dictates that most of the replicas of the relevant range must agree before the write is committed.