skip to content
~11 min

CAP theorem

Two data centres hold the same data. The link between them breaks. Each must now answer from its own copy, or refuse. CAP is the proof that there is no third way.

▸ start lesson

KataTube, a video site, has two data centres, EU and US. The link between them is down. Alice, a creator, just created a channel for her videos, named @nova. The US side can’t know.
· EU@nova→freeAlicesavedAliceKataTube · US data centre@nova→freeevery change is copieda Partitioncan't pass it onAliceBerlinnew channel@novacreate1owns @novaBobBoston2new channel@novacreatewaits for an answermust pick oneanswer, ok, it's yoursanswer “ok, it's yours”, but two ownersrefuse, try laterrefuse “try later”, but an error

prerequisites

  • Consistency models planned

mentioned lessons

  • Failure detection planned
  • Pacelc theorem planned
  • Conflict resolution planned

red flags

  • “CAP means pick two of three.”

    Networks fail whether you allow it or not. The only choice is consistency or availability, and only while the link is down.

  • “Available means the site is up.”

    In CAP every running server must answer, even one that can reach no other. A store with 99.99% uptime can fail that.

  • “Every database is CP or AP.”

    Many are neither, and one database can choose differently for each request.

after this lesson you can answer

  1. What do C, A and P mean, exactly?
  2. Why can't a store stay consistent and available while the link is down?
  3. “Is this database CP or AP?” Why is that the wrong question?

context