Code Room
System designHardsd-g202
Subject Leader electionLevel Senior–Staff~45 minCommon in Distributed systems interviewsIndustries Technology, Software development

Question

Design leader election for a sharded stream-processing system where each of 4,000 partitions must have exactly one active processor writing to a downstream sink. Processors run on autoscaled, preemptible VMs that can pause (GC, network partition) for tens of seconds. A second processor must never write the same partition's output concurrently, even if the 'old' leader is merely slow and not dead. How do you elect leaders and guarantee single-writer at the sink?

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.