“Hard” can mean different things (mathematically subtle, implementation-heavy, extremely easy to get subtly wrong, etc.). In day-to-day industry work, the algorithm family that checks all those boxes and is still everywhere in modern infrastructure is:
🚀 Distributed consensus — Paxos / Multi-Paxos / Raft / EPaxos / Zab
Why this one stands out
-
It’s widely used
• Google Spanner / Chubby, Amazon’s DynamoDB, Etcd, Consul, CockroachDB, Apache ZooKeeper, Kubernetes control-plane, etcd, TiDB, TiKV … all rely on a Paxos-style protocol.
-
It’s conceptually non-trivial
• You’re proving safety (“only one value is chosen”) and liveness (“eventually a value is chosen”) under an asynchronous network with crash/recovery failures.
• You have to reason in phases, with quorums, ballots, epochs, leases, and sometimes leader transfers.
-
It’s implementation-landmine heaven
• Handling retries, duplicate/out-of-order messages, disk persistence, reconfiguration, log compaction, read leases, back-pressure, flow control, snapshotting, byzantine network conditions… any tiny bug can cause split-brain or permanent unavailability.
• Clock skew and the CAP trade-offs lurk in every corner.
-
Formal proofs are not enough
• Lamport’s papers are proof sketches; the edge cases appear in the glue—serialization, RPC timeouts, disk corruption, partial replays, reboots in the middle of an fsync…
-
There isn’t one “correct” implementation
• Real systems blend Paxos with log replication tricks, batch proposals, pipelining, adaptive timeouts, group membership changes, etc.
• Performance tuning often invalidates naïve textbook invariants.
Other “honorable mentions”
If you look past consensus, the next tier of “often used yet notoriously hard to implement correctly” includes:
| Domain | Algorithm / Family | Pain Points |
|---|
| Cryptography | Constant-time elliptic-curve scalar multiplication (e.g., Curve25519, P-256) | Must be side-channel resistant, constant-time, formally verified; math + bit-twiddling + timing attacks |
| Compression | Zstandard’s optimal parsing, Brotli’s context modelling | Huge state machines, SIMD intrinsics, tricky integer overflows |
| Rendering | GPU shader compilation (SSA -> SPIR-V -> target), font shaping (HarfBuzz) | Gigantic spec surface, Unicode edge cases, hardware bugs |
| Database internals | Serializable snapshot isolation (SSI) + MVCC | Concurrency anomalies, predicate locking, phantom detection |
| SAT/SMT Solvers | CDCL(T) with clause learning, restarts, heuristics | Heuristic tuning, memory blow-ups, delicate balance between theory and engineering |
But if you poll developers running production systems, distributed consensus still wins the “most dreaded to build from scratch” trophy.
So… should I ever write my own Paxos/Raft?
Only if you have a very strong reason:
• Production teams almost always embed an existing battle-hardened library (etcd/raft, HashiCorp Raft, LibPaxos, JRaft, Dragonboat…).
• If you need to learn it, build a toy cluster (3 nodes, in-memory log) behind a façade (gRPC or QUIC), torment it with Jepsen-style nemesis tests (partitions, clock skew, random drops).
• Use model checkers (TLA⁺, Alloy, Ivy) before the first line of code.
• Never skip the “persistent storage between crashes” part—it’s where 80 % of real bugs live.
Learning resources
- Diego Ongaro’s PhD thesis — In Search of an Understandable Consensus Algorithm (Raft)
- “Paxos Made Simple” — Leslie Lamport (and the follow-up: “Paxos Made Moderately Complex”)
- Howard et al. — Raft Refloated (explanations of the gaps)
- etcd/raft or HashiCorp Raft source code (Go) annotated with the spec links
- Kyle Kingsbury’s Jepsen series on ZooKeeper, Etcd, Consul
TL;DR
If you’re looking for the algorithm that is simultaneously ubiquitous in real systems and hair-pullingly hard to implement correctly, distributed consensus (Paxos/Raft and friends) is the reigning champion.