Learn Labs
10. Consistency and Consensus

10. Consistency and Consensus

Chapter 10 of Designing Data-Intensive Applications — 11 sections.

"An ancient adage warns, 'Never go to sea with two chronometers; take one or three.'" — Frederick P. Brooks Jr.

The two competing philosophies for dealing with replica inconsistency:

Eventual consistencyStrong consistency
StanceThe fact that a system is replicated is MADE VISIBLE to the application; you as the developer are expected to deal with the inconsistencies and conflictsApplications should NOT have to worry about internal details of replication; the system should BEHAVE AS IF IT WERE A SINGLE NODE
Used byMulti-leader, leaderless replicationSingle-leader, consensus-based systems
AdvantageTolerates faults that break strongly consistent systems; inevitable if users make changes offlineSimpler for you, the application developer
DisadvantageCan be difficult for applications to deal withA performance cost, and SOME KINDS OF FAULT THAT AN EVENTUALLY CONSISTENT SYSTEM CAN TOLERATE CAUSE OUTAGES

If your replicas are located in datacenters with fast, reliable communication, STRONG CONSISTENCY IS OFTEN APPROPRIATE because its cost is acceptable.

The chapter's three movements:

The questionWhere the chapter goes
① “Strong consistency” is vagueLinearizability — a precise definition
② How do you generate IDs and timestamps?Logical clocks — closely connected
③ How do you get linearizability and fault tolerance?Consensus

These topics are NOTORIOUS for being hard to implement correctly. It's very easy to build systems that behave fine when there are no faults but COMPLETELY FALL APART when faced with an unlucky combination of faults or message orderings that their designers hadn't considered.