Skip to content
    Architecton

    DATABASES · 8 MIN

    CAP Theorem

    During a network partition, a distributed system must choose between Consistency and Availability.

    ARCH explains

    • C: every read sees the latest write. A: every request gets a response. P: system keeps working despite lost messages.
    • Partitions happen in real networks, so the real choice is CP or AP during them.
    • Banks lean CP; social feeds lean AP.

    Real world: Two branch offices lose their phone line — refuse orders (C) or accept them and reconcile later (A)?

    Code

    Partition happens →
      CP: reject writes until nodes agree
      AP: accept writes, reconcile later (eventual consistency)

    Checkpoint quiz

    A payments ledger typically prefers…