5 concepts · 10 practice questions
When a network partition splits replicas, a system must choose: refuse some requests to stay consistent, or keep answering and let replicas diverge. When there is no partition, the trade is latency against consistency. Consistency comes in degrees: linearizable (every read sees the latest write), read-your-writes, monotonic reads, and eventual (replicas converge if writes stop). In quorum systems with N replicas, writes wait for W acks and reads ask R replicas; when R + W > N, every read set overlaps the latest write set.
N, W, R = 3, 2, 2 # replicas, write acks, read replies
def write(key, value, version):
acks = sum(replica.put(key, value, version) for replica in replicas)
if acks < W:
raise WriteFailed()
def read(key):
replies = [replica.get(key) for replica in pick(replicas, R)]
# R + W > N: at least one reply holds the latest acknowledged write
return max(replies, key=lambda reply: reply.version)
Sign in to read the rest and take the 10-question test.
Sign in to continue