Anthropic ★★ Frequent Hard DynamoQuorum

A24 · Design a Key-Value Store (Dynamo-style) A24 · 设计键值存储(Dynamo 风格)

Verified source经核实出处

Prompt: "Design a Key-Value Store." — Exponent. Classic question. Credibility B/C.

Canonical Dynamo answer经典 Dynamo 解法

  • Consistent hashing with virtual nodes for load balance.一致性哈希 + 虚拟节点做负载均衡。
  • Replication factor N; quorum R/W with R + W > N for strong consistency.复制因子 N;读写 quorum R + W > N 实现强一致。
  • Vector clocks for conflict detection; client-side resolution or last-write-wins.向量时钟检测冲突;客户端解决或后写胜出。
  • Merkle trees for anti-entropy (detect divergent replicas).Merkle 树做反熵(检测分歧副本)。
  • Gossip for membership & failure detection.Gossip 做成员管理与故障探测。
  • Hinted handoff for write availability during node failures.Hinted handoff确保节点故障时写入仍可用。

Storage engine: LSM vs B-tree存储引擎:LSM vs B-tree

LSM-tree (like RocksDB): write-optimized, compaction background. Best default for KV. B-tree: better point-read latency but worse write amplification.LSM 树(如 RocksDB):写优化,后台 compaction。KV 首选。B-tree:点读延迟好但写放大差。

See also参阅

This answer is largely drawn from DDIA Ch. 5/6/9 and Alex Xu Vol. 1 Ch. 6. See the study guide pages for deeper treatment.本答案主要基于 DDIA 第 5/6/9 章Alex Xu Vol. 1 第 6 章。深度内容见学习手册。

Related study-guide topics相关学习手册专题