Iaroslav Kozlov Русский

Inside databases ScyllaDB

ScyllaDB

A distributed database, a drop-in replacement for Apache Cassandra 3.11: each node is split into shards, one thread to a core, and tables are split into tablets placed across the nodes.

My work

Provisioned on GCP with Terraform and Terragrunt; watched by the ScyllaDB Monitoring Stack, built on Prometheus and Grafana.

How it is built

A generalised layout from the ScyllaDB manual (branch 2026.3). Three nodes and a replication factor of three are an example; the memtable and the SSTables are drawn for one node only, and the commit log not at all. Terraform, Terragrunt and the monitoring stack are the tools of my work, not parts of ScyllaDB.

data control My part

While node 3 is down

unavailable

  • Prometheus can no longer pull node 3’s metrics. The InstanceDown alert that comes with the stack becomes active once its up metric has been 0 for 60 seconds; until then it is pending and is not sent.
  • The coordinator still sends each write to all three replicas; node 3 does not answer, so the coordinator stores a hint for it.
  • If the consistency level does not need all three replicas, the client is told the write succeeded.
  • When node 3 is back, the coordinator replays its hints. Once node 3 has been down for more than three hours (the default max_hint_window_in_ms), no new hints are created for it, and repair is still needed. 3 512

Components

Press a component to read what it does.

Terraform and Terragrunt

The tools ScyllaDB was provisioned with on GCP. Not part of ScyllaDB.

Client CQL

An application that reads and writes, and sets the consistency level of each operation.

Node 2 a replica

A node with a replica of the tablet the partition belongs to. Inside the node, tablets are balanced across its shards: each shard is one thread bound to one core.

Node 1 coordinator

The node the client sent its request to: for this request it is the coordinator. With three nodes and a replication factor of three it holds a replica too: replica nodes can also be coordinators, and often are.

Node 3 a replica

Another node with a replica of the same tablet.

Memtable in memory

A table in memory that the node writes its updates to and that serves both reads and writes. When it becomes too big, it is flushed to a new file. Drawn once, on node 2.

SSTables files on disk

Sorted String Tables: files sorted to make them easy to search and later merge, holding immutable rows, each identified by its row key.

Monitoring Prometheus

ScyllaDB Monitoring Stack on a server of its own: Prometheus collects ScyllaDB’s metrics and the host’s, Grafana shows them, Alertmanager handles the alerts. It runs outside the ScyllaDB cluster.

  1. Provisioning

    A ScyllaDB cluster is nodes acting in concert. Each node is split into shards: independent threads, each bound to its own core and given its own share of CPU, RAM and storage.

    My part I provisioned ScyllaDB on GCP with Terraform and Terragrunt.

    In detail

    Each ScyllaDB node is internally split into shards, each an independent thread bound to a dedicated core. Each shard is allotted CPU, RAM, persistent storage and networking resources, which it uses as efficiently as possible. The nodes of a cluster act in concert; changes to the schema and to the topology are agreed among them through Raft, as long as a quorum of the nodes is available. ScyllaDB is a drop-in replacement for Apache Cassandra 3.11, with additional features from Apache Cassandra 4.0. 1 27

    Where it breaks A shard sheds load: a request that is too large, or one beyond the maximum number of concurrent requests per shard, is dropped to protect the system. And if several nodes fail and the quorum is lost, the cluster takes no schema updates or topology changes.

  2. The coordinator

    A client sends its request to a node, which coordinates it. The consistency level, set by the client for each operation, says how many replicas must acknowledge it.

    In detail

    The client sends its request to a coordinator node; replica nodes can also be coordinators, and often are. The consistency level is a dynamic value that dictates how many replicas must acknowledge a read or write operation. The client sets it for each operation; in the CQL shell it defaults to ONE. 1 3

    Where it breaks Whatever the consistency level, a write is always sent to all the replicas the replication factor sets: the level controls when the client is acknowledged, not how many replicas are updated.

  3. Tablets and replicas

    Each partition maps to one tablet, and a tablet has its replicas on different nodes, as many as the replication factor. The coordinator sends the write to each of them.

    In detail

    ScyllaDB distributes data by splitting tables into tablets. Each partition of a table is mapped to a single tablet in a deterministic way, so ScyllaDB can quickly identify the tablet that stores it. Each tablet has its replicas on different nodes, depending on the replication factor, a setting of each keyspace. During a write, the coordinator communicates with the replicas, and the write is successful when the specified number of them confirm it. When nodes are added or removed, tablets are moved to keep the same number on each node, and in each node tablets are balanced across shards. 1 34

    Where it breaks Whether new keyspaces get tablets by default is set by the tablets_mode_for_new_keyspaces option, and tablets work only if every node of the cluster supports them.

  4. Writes

    On each replica the write goes into a memtable in memory. When it grows too big, it is flushed to a new sorted file, an SSTable, and compaction later merges SSTables.

    In detail

    ScyllaDB’s write path follows the Log Structured Merge design. It writes its updates to a memory table, which serves both reads and writes; when that becomes too big, it is flushed to a new file, sorted to make it easy to search and later merge: a Sorted String Table, or SSTable, of immutable rows. As soon as enough SSTables have accumulated, compaction merges several of them into new SSTables; which ones, and when, the compaction strategy decides. Unless durable_writes is turned off for the keyspace (it is on by default), updates also go to the commit log, which is not drawn here. 1 68

    Where it breaks Data later modified or deleted in another SSTable wastes space while both SSTables are there, and a read across many SSTables is slower; a bloom filter lets ScyllaDB skip SSTables that do not hold the partition.

  5. Hints

    If a replica’s node is down, the coordinator stores a hint, a copy of the write meant for it, and replays it when the node comes back. Repair is still needed.

    In detail

    A hint is a short record of a write request, held by the coordinator until the unresponsive node becomes responsive again; then the write is written to the replica, and once it is acknowledged the hint is deleted. The coordinator stores hints for nodes that are down and for replicas that do not respond within write_request_timeout_in_ms. 1 5

    Where it breaks For a node down longer than max_hint_window_in_ms, three hours by default, no new hints are made, and storing a hint can fail. Hints do not replace repair: a full repair has to be run regularly.

  6. Monitoring

    ScyllaDB Monitoring Stack runs on a dedicated server outside the cluster and collects ScyllaDB’s metrics and the host’s. Grafana shows them in dashboards; Alertmanager handles the alerts.

    My part Monitored with ScyllaDB Monitoring Stack: Prometheus and Grafana.

    In detail

    ScyllaDB Monitoring Stack is a full stack for monitoring and alerting, built from open source tools, Prometheus and Grafana among them, with ScyllaDB’s own dashboards. Prometheus collects and stores the metrics and generates alerts: it collects ScyllaDB’s metrics from ScyllaDB, which by default listens on port 9180 for Prometheus requests, and the host metrics from the node_exporter agent that runs on the ScyllaDB server. Loki makes metrics and alerts from the logs, and Alertmanager handles the alerts. The stack is installed on a dedicated server outside the cluster, with access to the nodes so that it can pull the metrics. 9 101112

    Where it breaks Prometheus alerts are defined in files under prometheus/prom_rules/. Changes to the alerts that come with the stack are overwritten at its next upgrade.

The whole diagram

ScyllaDB

Every component and step of the figure, drawn at once; the page lists them in text.

data control My part

Next engine

Aerospike

A distributed multi-model data store, key-value among its models: a record’s key places it in one of its namespace’s 4096 partitions, spread evenly over the nodes, and the client sends reads and writes to the partition’s data master.

Inside Aerospike Inside databases