Part 5 of 6 · 2 min read
Using the ideas in a design
Decide per feature, state the user-visible behaviour, and name what you give up.
Using the ideas in a design
Think of an airline. Seat selection must never double-book, so it can refuse during trouble. The "flights near you" list can be a little old without harm. One airline, two different promises.
A good design does not label the whole system CP or AP. It lists the features and, for each, says what the user sees when replicas cannot talk, and what it costs when they can.
A worked example, a ticket shop (made up to show the idea).
| Feature | During a partition | Normal day | Model (module 6) |
|---|---|---|---|
| Buy a ticket | Refuse if the seat count cannot be confirmed by a majority | A write waits for a majority, tens of ms | Linearizable on the seat count |
| Show tickets left | Show last known count, mark "approximately" | Served from the nearest replica | Eventual |
| Order history | Show what this region knows | Local read | Read your own writes at least |
| Admin report | Delay until the partition heals | Run from a snapshot | Snapshot (module 2) |
Why this works: only the part with a hard rule (never oversell) pays for strong consistency. The rest stays fast and available.
Steps for an interview answer:
- List the data items and their rules ("never negative", "may be a minute old").
- For each rule, pick a model from the ladder (module 6).
- Say what happens in a partition for each, in the user's words.
- Say what the strong parts cost on a normal day (latency) and how you limit it, for instance with a majority instead of all replicas.
- Say how recovery works when the link returns (merge, replay or catch-up).
Check yourself:
- Why not label the whole shop CP?
- What does the design do on a normal day for the seat count, and what does it cost?
Words you will meet
| Word | Plain meaning |
|---|---|
| CAP theorem | During a partition, choose consistency or availability |
| Consistency (in CAP) | Every read sees the latest write, like one copy |
| Availability (in CAP) | Every request to a working node gets a response |
| Network partition | A network fault that splits nodes into groups that cannot talk |
| CP system | Keeps consistency and may refuse requests during a partition |
| AP system | Keeps answering during a partition and may be stale |
| PACELC | CAP plus: else, choose latency or consistency |
| Latency | How long one operation takes |
| Tunable consistency | A setting that moves a store along the consistency and speed trade-off |
| Stale read | A read that returns an older value |