AlgoViz

The CAP theorem

medium 28 min

When the network between copies of your data breaks, each copy must either refuse some requests or risk answers that disagree.

Where it shows up

The same pattern appears across everyday software.

  • Cluster configuration

    etcd and ZooKeeper hold locks, leaders and settings. They refuse on the minority side, because two leaders would be worse than a short wait.

  • Shopping carts

    The Dynamo paper describes a cart that must always accept an item. Versions that diverged are handed to the application, which merges them.

  • Airline seats

    The last seat needs one authority. Some companies overbook on purpose and repair with compensation, which is an AP choice with a business rule.

  • Cash machines

    Brewer's 2012 article describes machines that go on during a split but limit the amount, so that the possible damage is bounded.

  • DNS

    Resolvers answer from cache even when the owner of the zone cannot be reached. Old answers expire after their time to live.

  • Offline apps

    A phone in a tunnel is a partition. Notes apps accept the edit and merge later: AP with a user interface.