← All Articles

Raft Leader Elections Under Real Network Chaos

How election timers, heartbeat jitter, and fsync latency interact in production Raft clusters, and what to tune before split-brain scares your team.

Leader election bugs in production usually come from timing assumptions that hold in staging but collapse under packet reordering and storage jitter.

Hidden Inputs That Skew Elections

  • Disk flush latency spikes on leaders.
  • Noisy neighbors causing cgroup CPU throttling.
  • Clock jitter in virtualized environments.
// Election timeout should be randomized and significantly larger
// than heartbeat interval to reduce collision probability.
heartbeat := 100 * time.Millisecond
electionMin := 600 * time.Millisecond
electionMax := 1200 * time.Millisecond

Practical Guardrails

  1. Keep election timeout at least 5x heartbeat.
  2. Track term-change rate as an SLO signal.
  3. Separate WAL IO from snapshot IO paths.

Consensus systems fail in the margins. Measure the margins.

Next ArticlePostgres Index Bloat and Fillfactor StrategiesDatabases · 13 min read