Skip to main content

001 · MIT 6.824 / 6.5840 — Raft

项目 内容
学校 MIT
课程 MIT 6.824 / 6.5840 Distributed Systems
方向 分布式系统 / Distributed systems
语言 Go
难度 硬核 / Advanced
预计耗时 5–10 天 / 5–10 days

为什么收录

Raft 要求实现共识算法:leader 选举、日志复制、持久化与安全性。难点不在代码量,而在对并发与故障的推理——这正是最能锻炼思考能力的那类题目。

Raft requires implementing consensus: leader election, log replication, persistence, and safety. The difficulty lies in reasoning about concurrency and failures — exactly the kind of problem that builds deep thinking.

English: Raft is a capstone in reasoning, not just coding: correctness under network partitions and crashes forces students to reason about invariants rather than APIs.

实测结果

  • 4 项测试全部通过(选举、日志复制、leader 故障转移、分区安全)/ 4 tests pass
  • go test -race 无数据竞争 / no data races
  • 详见 05-调试与测试.md 中的真实输出 / real output in chapter 05

七章解析

题目解读 · 设计思路 · 逐步实现 · 正确性与复杂度 · 调试与测试 · 踩坑清单 · 延伸练习

源码与测试

题目目录 · 参考实现 · 测试