Data Consistency across Continents
What this lesson covers
Consistency means that multiple copies of the same data are the same. A cache on the Harvard server reduces latency for Oxford profiles, but a cache miss still goes to Oxford. The practical fix is multiple copies of the data, one in the US and one in Europe. There is no single point of failure, because if one server crashes the other serves the data. Latency is low, because an update is made locally and the response is sent back. The update then has to propagate to the other copy. A real time system sends the update over TCP, which gives reliable and ordered delivery. The open problem is a failed transmission. The fix is an acknowledgement. The acknowledgement fails too, so the US server retries. A server that commits locally cannot depend on its peer to commit, because the network is unreliable. An acknowledgement of the acknowledgement is an infinite process. This is the two generals problem. So the US server becomes the leader, the only one that writes to the database. The Europe server is a follower: it gets regular updates from the leader and serves reads. If an update does not go through, a follower that answers gives a dirty read, and a follower that waits is not available. Pure consistency costs availability, and availability brings inconsistencies.
- A cache reduces latency across continents, and a cache miss still goes to the other server
- Copies of the data in two regions remove the single point of failure and keep latency low
- Over an unreliable network a server cannot depend on its peer to commit: the two generals problem
- In a leader-follower architecture only the leader writes, and followers get its updates and serve reads
- A follower that answers gives a dirty read, and a follower that waits is not available