Leader-follower replication
Almost every production database keeps copies of its data on other machines: one copy takes the writes and the others follow it. Interviewers expect you to say which copy takes writes, whether a commit waits for a copy, and what happens when the leader dies.
The league results office
A sports league keeps one official results table. Only the head office writes in it: when a match ends, the official enters the score. Every change is sent, in order, to the regional offices, which copy it into their own tables and answer fans' phone calls. A fan who rings a regional office may hear a result that's a few seconds old. If the head office floods, the league names one regional office as the new head office and everyone sends results there. What the league must never have is two head offices writing different results at the same time.
- the head office → the leader (or primary): the only copy that takes writes
- the official entering a score → the app writing a row, here the order service
- the changes, sent in order → the replication log
- the regional offices → followers (replicas, standbys): they apply the changes
- fans' calls → reads
- a result a few seconds old → replication lag
- naming a new head office → failover
- two head offices writing different results → split brain