System Design: PACELC theorem
This course covers the PACELC theorem, which extends CAP with an else case: without a partition, a system chooses between latency and consistency. The lessons apply it to a single-node Rails application that has no partitions but makes seven else-case decisions through its caches. They cover the four classes PA/EL, PA/EC, PC/EL and PC/EC, and key-based versus time-based caching. Later lessons show where consistency costs latency, three ways to measure staleness, and how to choose a staleness budget as a product decision. It ends with a coding challenge.
What you'll learn
- ✓The PACELC statement and why the else case applies to nearly every request
- ✓The four classes and why a path through a system has a class
- ✓When to use key-based caching and when to use time-based caching
- ✓Where consistency costs latency, and who waits for it
- ✓Three ways to measure staleness, from reading the config to comparing cached and fresh values
- ✓Four questions for setting a staleness budget as a product decision
The else case
CAP describes what happens during a network partition. PACELC adds the sentence CAP is missing: and the rest of the time.
Read the full lesson free →Curriculum
7 lessonsThe else case
PACELC adds the else case to CAP, and a single-node application makes seven such decisions and zero partition ones.
The four classes
The four classes PA/EL, PA/EC, PC/EL and PC/EC, with examples, and why each path through a system has its own class.
Key-based versus time-based
Key-based caching puts every input in the key, while time-based caching suits aggregates with no natural version.
Where consistency costs latency
Five places where consistency costs latency, showing that consistency is bought with waiting and the question is who waits.
Measuring staleness
Three ways to measure staleness: read the config, store generated_at in the value, and compare cached against fresh values.
Choosing a budget
A staleness budget is a product decision, set by four questions and recorded where both engineering and product read it.
Putting it together
A summary of the course, a three-part review question, and a challenge that classifies a cache by PACELC class.