One machine from many showed a healthy fleet sharing work. This essay is about everything that goes wrong: machines dying mid-write, networks splitting a cluster in half, and the arithmetic and choreography that keep the data whole through all of it.
Machines fail, routinely. So each shard keeps understudies, replicas, full copies on different nodes, which serve reads in the meantime. Index a few documents, then kill a node:
No human decides anything: the cluster notices missing heartbeats, promotes replicas, rebuilds spares on the survivors, and searches keep flowing throughout. This is how a reliable service is built from unreliable computers.
But who exactly "notices"? Who decides which replica gets promoted? A cluster of equals with no referee would tear itself apart, so Elasticsearch nodes hold roles. Data nodes hold shards and do the heavy work; any node can play coordinator for a request, as in One machine from many; ingest nodes run the ingest pipelines (see the life of a log); and a small set of master-eligible nodes can hold the one job that must never be held twice: the elected master, sole owner of the cluster state, the versioned map of every index, mapping, and shard location that every node carries a copy of, but only the master may change.
The danger is obvious: if a network hiccup splits the cluster and both halves elect a master, both halves accept writes, and the data diverges irreparably; the dreaded split-brain. The defense is arithmetic: electing a master requires a quorum, a strict majority of the master-eligible nodes, and no two halves of a split can both hold a majority. Test it:
Notice the philosophy in the failure case: a group without a majority doesn't guess, it steps down and refuses writes. Elasticsearch would rather be briefly unavailable than quietly wrong; unavailability heals, divergence doesn't.
The same thinking extends outward in rings. Replicas are placed with allocation awareness, never in the same rack or availability zone as their primary, so one flooded datacenter room doesn't take both copies. And for the largest deployments, cross-cluster replication keeps an entire second cluster in another region following the first, ready to take over, while cross-cluster search lets one query span them all.
Failure is the dramatic case; the everyday case is change. You add a node, and the cluster should use it; an index grows hot, and its shards should spread. The master continuously solves this placement puzzle under hard rules (never a replica beside its primary; respect zone awareness) and soft goals (balance shard counts and disk). Resize the cluster:
Promotion is instant, but it leaves the cluster one copy short, and the replacement replica is not conjured, it is recovered: built from the primary while writes continue to flow. The process has two phases, and knowing them explains most recovery dashboards you will ever stare at:
Nodes fail one at a time; datacenters fail all at once. If both copies of a shard happen to sit in the same availability zone, the replica bought you nothing the day the zone goes dark. Allocation awareness teaches the allocator geography:
The last line of defense is the snapshot: a copy of the data in object storage, outside the cluster's fate entirely. Snapshots here have a superpower inherited, once again, from immutability: since segment files never change, snapshot two does not re-upload what snapshot one already stored:
Notice how often the answer was immutability: recovery copies files that cannot change, snapshots share them, and the rest of the machine leans on the same trick. Related: the immutable segments that make replication and snapshots cheap, and the search path all this reliability exists to protect.