分布式系统百科
· etcd 深度解剖 已从 Watch/MVCC/Lease 讲过协调层全景;Raft
深度重写 与 Raft
实现拆解 讲过 etcd/raft 工程补丁;分布式 KV
对比 把 etcd 放在 TiKV、FoundationDB
选型海报里。中间仍缺一层:一次写入卡在 Raft propose
还是 MVCC apply、线性一致读与 follower 读如何分列、Watch
从旧 revision 追赶为何触发 ErrCompacted、Lease
KeepAlive 不经 Raft 时 Leader 切换如何影响 TTL、K8s
apiserver 耦合下 resourceVersion 与 Node Lease
落在哪一层,以及 quota/单写者触顶时何时该迁 Multi-Raft
而非继续调参。
本系列回答:etcd 生产路径里读写与 Watch 失败落在哪一层,Revision MVCC + bbolt 相对 Multi-Raft 换来了什么排障坐标,以及何时应离开 etcd 协调叶。
写:
- 单 Raft 组与 etcdserver 角色;WAL/快照恢复;Revision MVCC + treeIndex + bbolt。
- Apply 管道、ReadIndex/一致性读、Watch/watchableStore、Lease/checkpoint、Txn 边界。
- Compaction/quota/defrag、K8s 控制面耦合、运维升级、排障五轴、相对 TiKV/FDB/ZK 的选型。
不写:Raft 论文全书、apiserver 存储实现全书、TiKV/FDB 内核重讲、Kine 兼容层全书、未实测 QPS 排行。不把 etcd 写成通用数据库。 Raft 补丁见 distributed/13;Multi-Raft 见 tikv-htap/;Unbundled 见 foundationdb/。
系列状态:01–16 已发布(2026-08-26)。 规划见 PLAN.md。机制结论钉源码 tag
v3.5.33(etcd v3.5.33,2026-07-23 补丁线),不以etcd.io/docs/latest冒充该版本。无真实 etcd 集群则不粘贴伪造etcdctl endpoint status/check perf输出。实验台账未跑。
版本锚定:etcd v3.5.33(源码 tag
v3.5.33)。Kubernetes 控制面常见嵌入 3.5.x——正文机制以该 tag 为准。3.6/3.7 升级差异只在第 14 篇列出门禁项,不超前写未钉 tag 能力。
适合谁看
- 平台 / SRE,要把「K8s 控制面 etcd 健康」推进到「能归因 Raft→WAL→MVCC→Watch→Lease 五轴」。
- 读过 distributed/50 或 39,需要 etcd 生产内核全书坐标的读者。
- 在 etcd、TiKV、Consul/ZK 之间做协调层选型的架构师。
与已有系列的分工
| 维度 | distributed/50 / 39 | 本系列 |
|---|---|---|
| 定位 | Watch/MVCC 百科单篇;三方选型海报 | 生产服务器内核 + K8s 底座耦合 |
| 深度 | 机制概览、开放问题列表 | propose→apply→watch 链、五轴排障 |
| 对照 | TiKV/FDB 表格 | 显式排除树;不重写姊妹全书 |
| 症状 / 问题 | 去看 |
|---|---|
| Raft PreVote / 流水线 / ReadIndex 代码 | distributed/13、raft-etcd |
| Jepsen / Lease 锁边界 | distributed/53 |
| Multi-Raft / Region / HTAP | tikv-htap/ |
| Unbundled / OCC | foundationdb/ |
| no leader / quota / ErrCompacted / Lease TTL | 本系列 15 |
| 该不该继续 etcd vs 上 TiKV | 本系列 16 |
读法:只要「K8s 靠 etcd Watch」→ distributed/50 足够;要「Raft lag vs apply lag、Compaction SLO、apiserver 超时是否 etcd 轴」→ 本系列 01 → 03 → 08 → 09 → 15。
一、这个领域最值得关注的 5 个问题
- 一次 Put/Txn 从 gRPC 到 Watch 推送,失败落在哪一层? → 第 1–7、15 篇。
- 线性一致读、Serializable 读、Lease read 如何分列?follower 读何时不安全? → 第 8、15 篇。
- Watch
背压、
ErrCompacted、historical revision 追赶如何写进 SLO? → 第 9、13、15 篇。 - Lease/KeepAlive 与 Leader 切换、K8s Node Lease 如何耦合? → 第 10–11、13 篇。
- 何时继续 etcd,何时 TiKV/FDB/ZK?quota 否证条件是什么? → 第 16 篇。
二、篇目依赖关系与推荐阅读路径
flowchart TD
overview["01 Overview"] --> raft["02 Single Raft"]
raft --> wal["03 WAL Snapshot"]
wal --> mvcc["04 MVCC Model"]
mvcc --> bbolt["05 bbolt Backend"]
bbolt --> apply["06 Apply Pipeline"]
apply --> write["07 Write Path"]
write --> read["08 Read Consistency"]
read --> watch["09 Watch"]
watch --> lease["10 Lease"]
lease --> txn["11 Txn Semantics"]
txn --> cap["12 Compaction Quota"]
cap --> k8s["13 K8s Coupling"]
k8s --> ops["14 Ops Upgrade"]
ops --> trouble["15 Troubleshoot"]
trouble --> select["16 Selection"]
overview --> select
| 路径 | 篇目 | 适合 |
|---|---|---|
| 必读核心 | 1 → 3 → 6 → 8 → 15 | 快速建立五轴 |
| K8s 控制面 | 1 → 9 → 10 → 13 → 15 | apiserver 超时归因 |
| 容量与运维 | 4 → 7 → 12 → 14 | quota/defrag/升级 |
| 对照选型 | 1 → 16 | 协调层路径选型 |
| 完整通读 | 1 → … → 16 | 系统掌握 |
三、目录与每篇价值点
第一部分:共识与持久化(01–05)
- 生产全景
- 相对 distributed/50、39 的缺口;五轴与 16 篇路线。
- 单 Raft
组与服务器角色
- Leader/Follower/Learner;与
etcd/raft边界。
- Leader/Follower/Learner;与
- WAL
与快照
- 预写日志、snapshot、crash recovery;commit vs applied。
- MVCC
数据模型
- Revision、keyIndex、generation。
- bbolt
后端
- mmap、batch、单写者约束。
第二部分:读写、Watch 与租约(06–11)
- treeIndex
与 Apply 管道
- propose → commit → apply;watch 触发点。
- 写入路径深读
- Txn、quota、alarm。
- 读路径与一致性
- ReadIndex、Serializable、Lease read。
- Watch
机制
- watchableStore、synced/unsynced、
ErrCompacted。
- watchableStore、synced/unsynced、
- Lease 与
KeepAlive
- grant/KeepAlive/checkpoint;Leader 切换。
- Txn
与并发语义
- compare/mod;Jepsen 边界指针。
第三部分:K8s、运维与收束(12–16)
- Compaction、Defrag
与容量
- auto-compaction、defrag、SLO。
- Kubernetes
控制面耦合
- apiserver、resourceVersion、Node Lease。
- 运维与升级
- member change、backup/restore、3.5→3.6/3.7 门。
- 排障五轴
- Raft/WAL/MVCC/Watch/Lease 口令表。
- 选型收束与开放问题
- 排除树;回收 distributed/39 的 etcd 叶。
参考
- PLAN.md — 逐章大纲、来源/实验/研究台账
- distributed/50 · etcd 深度解剖
- distributed/39 · KV 存储对比
- etcd 官方文档 v3.5
返回 全部系列索引
读完这篇,下一步读什么
优先读同系列或同问题的下一篇,把单篇消费变成主题集群。
【etcd】生产全景:缺口、五轴坐标系与 16 篇路线
相对 distributed/50、39、13 钉清 etcd 生产内核缺口;定义 Raft/WAL/MVCC/Watch/Lease 五轴排障坐标系,给出 16 篇阅读路线与 K8s 控制面耦合指针。版本锚定 v3.5.33。
【etcd】排障五轴:Raft/WAL/MVCC/Watch/Lease 口令表
按 Raft、WAL、MVCC、Watch、Lease 五轴做症状否证;解释 etcdctl endpoint status/health 字段语义;并对照 K8s 控制面 apiserver 超时与 Node Lease 漂移。
【etcd】treeIndex 与 Apply 管道:propose → commit → apply
走读 etcd v3.5.33 从 Raft commit 到 MVCC apply 的串行管道:treeIndex 与 bbolt 分工、consistent index、watchableStore 通知触发点,以及 committed/applied 分列排障。
【etcd】Kubernetes 控制面耦合:apiserver、resourceVersion 与 Node Lease
钉 kube-apiserver 与 etcd 的分层边界;resourceVersion 如何映射 Revision MVCC;Node Lease 如何落在 Lease 轴;以及 apiserver 超时应如何分列到 Raft/Watch/Quota 五轴。