Iaroslav Kozlov Русский

Inside databases Aerospike

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.

My work

A cluster deployed in the cloud: namespaces and their storage set up, cross-datacenter replication with XDR.

How it is built

A generalised layout from the Aerospike documentation (Database 8.2 was its latest on 2026-11-25). Two nodes, a replication factor of two and one remote cluster are an example; the index and the write blocks are drawn for one node only. XDR is available only in the Enterprise Edition.

data My part

After the cluster re-forms · an AP namespace, RF 2 · one partition shown

the route after the failure unavailable takes over

  • In this two-node example, the surviving node holds the replicas of the partitions node 1 was the master of.
  • When a partition’s master fails and a replica is promoted to master, the new master takes over XDR shipping where the failed master left off.
  • With one node left, an AP namespace keeps one copy of each partition: its effective replication factor drops to the number of nodes in the cluster. 1 5

Components

Press a component to read what it does.

Data master its partition

The node that is the data master of this record’s partition: every read and write of the partition is sent to it for processing. Every node is the master of some partitions and holds replicas of others: all nodes are peers.

Node 2 the replica

The node that holds the replica of this partition. It saves the record it is sent, and confirms the write.

Client location-aware

The Aerospike client is location-aware: it knows where each partition is, and sends reads and writes to the data master, so data retrieval takes a single hop.

Primary index in memory

A 64-byte entry for every record of the namespace: its 20-byte digest, metadata such as its generation and the time it expires, and the exact place of the record on the storage device. In RAM by default; in Enterprise Edition it can also be kept in persistent memory or on an NVMe SSD.

Write blocks on SSD

The storage of a namespace: records are appended sequentially into empty, fixed-size write blocks, 8 MiB each from Database 7.1. Defragmentation copies the live records out of blocks that updates and deletes have left with stale ones.

Cluster B datacenter 2

Another Aerospike cluster, in another datacenter, that XDR ships the changes to. In an active-passive topology clients write only to the first cluster, and this one can be used for reads.

  1. Partitions

    Each namespace has 4096 partitions, spread evenly over the nodes: each of n holds about 1/n of the data. With two copies, every node masters some partitions and replicates others.

    My part I deployed an Aerospike cluster in the cloud.

    In detail

    Each namespace is divided into 4096 logical partitions, which are evenly distributed between the cluster nodes: with n nodes, each stores about 1/n of the data, and there is no need for manual sharding. With a replication factor of 2, each node is the data master for some partitions and the replica for others. Each partition has an ordered list of nodes, its succession list: the first node holds the master copy, the next the first replica. Heartbeats maintain the integrity of the cluster; cloud providers such as Amazon and Google Compute Engine do not support multicast, and for them the documentation says to use mesh heartbeats, point-to-point TCP connections. 1 6

    Where it breaks Network latency on cloud platforms is often not consistent over time, which can cause problems with the delivery of heartbeats: for such providers the documentation recommends a heartbeat interval of 150 ms and a timeout of 20 intervals, that is 3 seconds.

  2. One hop

    A record’s key is hashed into a 20-byte digest; 12 bits of it give the partition. The client knows where each partition is and sends the request to its master: retrieval takes a single hop.

    In detail

    A deterministic hash maps a record to a single partition: the record’s key, of any size, is hashed into a 20-byte fixed-length digest using RIPEMD160, and the partition ID is determined using 12 bits of this digest. The client is location-aware: it knows where each partition is located, so the data retrieval is achieved in a single hop, and every read and write request is sent to the data master for processing. 1

    Where it breaks In rare cases, while the cluster is being reconfigured, the client is briefly out of date and sends a request to the wrong node; the request is then proxied to the right one.

  3. Writes

    The master appends the record to a write block in the namespace’s storage. Its 64-byte entry in the primary index, in memory by default, holds the exact place of the record.

    My part I set up the namespaces and their storage.

    In detail

    A namespace is a collection of records that share one storage engine, with common policies such as the replication factor; each namespace is configured separately, so small ones can use RAM and larger ones SSDs. Writes are appended sequentially into empty, fixed-size write blocks; from Database 7.0 the engines for SSD, persistent memory and memory share this format. The primary index, in memory by default, holds a 64-byte entry for every record, with the exact location of the record on the storage device, which supports retrieving it with a single read IO. 2 3478

    Where it breaks Stop-writes keeps client writes from filling a namespace’s storage beyond its thresholds: when the ratio of free write blocks to the storage engine’s capacity drops under stop-writes-avail-pct, 5% by default, client writes stop; deletions, replica writes and migration writes are still allowed.

  4. Replication

    The master saves the record and forwards it whole to the node with the replica. Once the replica confirms and the master has written it too, the client gets its confirmation.

    In detail

    Most deployments use a replication factor of 2: a master copy and one replica of every partition, each node the master of some partitions and the replica of others. When a node receives a write request, it saves the data and forwards the entire record to the replica node; once the replica node confirms a successful write and the node writes the data itself, a confirmation returns to the client. With synchronous replication, writes propagate to all replicas before the data is committed and the result returned. 1

    Where it breaks When a cluster recovers from being partitioned, writes to the different copies may conflict: Aerospike then picks the most likely version by a heuristic, by default the one with the most changes, the highest generation count.

  5. XDR to another datacenter

    XDR ships the changes of a namespace asynchronously to a cluster in another datacenter. The master of each partition ships the writes of that partition.

    My part I set up cross-datacenter replication with XDR.

    In detail

    XDR asynchronously replicates cluster changes over higher-latency links, typically WANs; it is available only in Enterprise Edition. The master for any partition is responsible for replicating the writes of that partition. Specific namespaces can be shipped to specific remote clusters, and within them only specific sets or bins. In an active-passive topology clients write only to one cluster, and the other can be used for reads. If the link to a remote cluster drops, each master node records when it went down and shipping to that cluster is suspended; when the link is back, new writes are shipped as before, and so are the writes held back meanwhile. 5

    Where it breaks Where both clusters take writes (active-active), bin convergence settles a conflict by each bin’s last update time: it ensures only final-state convergence, not eventual consistency, and may lose intermediate updates.

The whole diagram

Aerospike

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

data My part

Next engine

MySQL

A relational database server. Its InnoDB engine keeps each table’s rows in a clustered index, a B-tree of pages; replicas repeat the changes the source writes to its binary log. Here it is Percona Server for MySQL, a drop-in replacement for MySQL, behind ProxySQL, with Orchestrator for failover.

Inside MySQL Inside databases