"매 update 후 충분한 시간이 지나면 매 모든 replica 가 같은 값에 수렴한다". 매 Eventual Consistency는 CAP theorem 의 AP 선택 — strong consistency 의 latency/availability cost 대신 매 staleness 허용. DynamoDB, Cassandra, Riak 의 default model. 2026 globally-distributed system 의 매 default trade-off.
매 핵심
매 CAP & PACELC
CAP: partition 시 Consistency vs Availability 택 1
PACELC (Abadi): partition 없을 때도 Latency vs Consistency
매 Eventual = AP + EL (Else Latency)
매 strong consistency 는 quorum write/read latency cost
매 BASE vs ACID
Basically Available: 매 partial failure 시 partial response
Soft state: 매 state 는 변할 수 있음 (replica sync)
Eventual consistency: 매 시간이 지나면 수렴
매 ACID와 trade-off — choose per use case
매 응용
DNS (TTL-based eventual).
CDN cache invalidation.
Social media feed (read-your-writes는 보장).
Shopping cart (Amazon Dynamo paper).
💻 패턴
Cassandra tunable consistency
fromcassandra.clusterimportClusterfromcassandraimportConsistencyLevelfromcassandra.queryimportSimpleStatementcluster=Cluster(['node1','node2','node3'])session=cluster.connect('myapp')# 매 write: ONE = fast, eventual; QUORUM = strongerwrite=SimpleStatement("INSERT INTO users (id, name) VALUES (%s, %s)",consistency_level=ConsistencyLevel.QUORUM)session.execute(write,(user_id,name))# 매 R + W > N → strong consistency# 매 R=1, W=1, N=3 → eventual
CRDT (G-Counter, conflict-free)
classGCounter:def__init__(self,node_id:str):self.node_id=node_idself.counts={node_id:0}defincrement(self):self.counts[self.node_id]+=1defvalue(self)->int:returnsum(self.counts.values())defmerge(self,other:'GCounter'):# 매 idempotent + commutative + associativefornid,countinother.counts.items():self.counts[nid]=max(self.counts.get(nid,0),count)
upstreambackend{ip_hash;# 매 same client → same backend → reads see own writes
serverbackend1;serverbackend2;serverbackend3;}
Last-Write-Wins (DynamoDB style)
deflww_merge(local:dict,remote:dict)->dict:ifremote['updated_at']>local['updated_at']:returnremoteelifremote['updated_at']<local['updated_at']:returnlocalelse:# 매 tie-break by node_idreturnremoteifremote['node_id']>local['node_id']elselocal
Hinted Handoff (Cassandra)
# cassandra.yamlhinted_handoff_enabled:truemax_hint_window_in_ms:10800000# 매 3 hours# 매 down node 회복 시 hint replay → eventual consistency 보장
Anti-Entropy (Merkle tree sync)
defmerkle_sync(local_tree,remote_tree,path=""):iflocal_tree.hash==remote_tree.hash:return# 매 subtree identical, skipiflocal_tree.is_leaf:sync_data(path)returnfori,(l,r)inenumerate(zip(local_tree.children,remote_tree.children)):merkle_sync(l,r,path+f"/{i}")
매 결정 기준
상황
Consistency
Bank transfer
Strong (linearizable)
Social feed
Eventual
Shopping cart
Eventual + LWW
Counter (likes, views)
Eventual + CRDT
Configuration / leader election
Strong (Raft, etcd)
User profile
Read-your-writes
기본값: 매 eventual + CRDT (counter, set, register). 매 money / lock / unique-id 는 strong.
언제: 매 system design interview, distributed DB 선택, conflict resolution strategy.
언제 X: 매 financial transaction, inventory deduction — strong consistency 필요.
❌ 안티패턴
모든 곳에 eventual: 매 money/lock 도 eventual → 매 double-spend, race.
Conflict ignore: 매 LWW만 쓰고 user-visible conflict 무시 → 매 silent data loss.
No bounded staleness: 매 sync 영원히 안 됨 → "eventual" 의미 무.
Vector clock 무한 성장: 매 GC/pruning 없음 → 매 metadata explosion.
🧪 검증 / 중복
Verified (DeCandia et al., "Dynamo: Amazon's Highly Available Key-value Store", 2007).