Designing Data-Intensive Applications
Ch. 9

Linearizability

Linearizability makes a replicated system behave as if there were only one copy of the data.

Linearizability (also called strong consistency or atomic consistency) is the strongest single-object guarantee. It makes concurrent operations appear to execute in some sequential order that respects real-time ordering.

Cost

Linearizability requires consensus on every operation — adding latency and reducing availability during network partitions.

In practice

Kubernetes uses etcd for linearizable leader election and config storage. ZooKeeper coordinates Kafka brokers (legacy) and Hadoop. Distributed locks (Redisson on Redis, etcd leases) need linearizable compare-and-set. Spanner offers external linearizable reads globally — rare and costly; most apps settle for per-partition ordering in Kafka instead.

LinkedIn at scale

Job-posting deduplication and distributed locks for recruiter workflows require linearizable compare-and-set via etcd — only one worker may hold the lock at a time.

typescript — Linearizable compare-and-set lock
// LinkedIn distributed lock — linearizable compare-and-set
async function acquireLock(resource: string): Promise<boolean> {
  const ok = await etcd.put(resource, nodeId, {
    prevExist: "false", // only succeeds if key absent — atomic
  });
  return ok;
}
// Stale leader cannot steal lock without seeing current holder
Key Takeaways
  • Every operation appears to take effect atomically at some instant.
  • Once a write completes, all subsequent reads see it.
  • Compare-and-set and distributed locks require linearizability.
  • Implementing linearizability requires coordination — often a single leader.
  • The CAP theorem: during a partition, choose consistency or availability.
  • etcd, ZooKeeper, and Spanner provide linearizable operations for coordination and storage.
linearizabilityetcdZooKeeperCAP theoremSpannercompare-and-set