1. Consistency
Consistency means every node returns the same, latest data for a read.
consistency: all-nodes-same-dataTyporithm · medium
Step 1 of 8 · intro card
Fundamentals
The CAP theorem says that during a network partition you must choose consistency or availability. Strong consistency returns the latest write everywhere, eventual consistency converges over time — the ACID vs BASE split — and PACELC adds the latency tradeoff when there is no partition.
The CAP theorem is about behavior during a network partition. When nodes cannot all communicate, you must choose: stay consistent (CP) by refusing or delaying responses, or stay available (AP) by answering with possibly stale data. You cannot have both while partitioned.
Consistency models sit on a spectrum. Strong consistency guarantees every read sees the latest write across all nodes; eventual consistency lets replicas diverge briefly and converge over time. This maps to ACID (strong, transactional) versus BASE (basically available, soft state, eventual).
PACELC extends CAP: if there is a Partition, choose Availability or Consistency; Else (normal operation) choose between Latency and Consistency. It captures that even without partitions, strong consistency costs extra latency.
During a partition: pick consistency (CP) or availability (AP).
Strong consistency = latest write everywhere; eventual = converges over time.
PACELC adds the latency-vs-consistency tradeoff when there is no partition.
cap:
consistency: all-nodes-same-data
availability: always-responds
partition_tolerance: survives-split
tradeoff: pick-cp-or-ap
models: strong-vs-eventualConnect each part of the code to the concept before you type.
Consistency means every node returns the same, latest data for a read.
consistency: all-nodes-same-dataAvailability means every request gets a non-error response, even if it is not the newest data.
availability: always-respondsPartition tolerance means the system keeps working when the network splits nodes into groups that cannot talk.
partition_tolerance: survives-splitDuring a partition you must drop either consistency (AP) or availability (CP) — you cannot keep both.
tradeoff: pick-cp-or-apStrong consistency returns the latest write everywhere; eventual consistency converges over time.
models: strong-vs-eventualRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.