KatInterview

Design a Consent-Aware Distributed Load-Shedding System

System DesignModel answer
HardModel answerSystem Designdistributed-systemsreal-timeoptimization

Last updated

Design a distributed controller that sheds megawatts of electrical load across millions of smart devices within seconds while honoring user preferences, device safety rules, and fairness.

Context

Power grids are increasingly made up of edge-connected devices — home batteries, EV chargers, heat pumps, and solar inverters. When generation falls short of demand, operators must shed load within seconds to prevent cascading failures. Traditional approaches cut entire neighborhoods without discrimination. Your task is to design a smarter system.

Problem

Design a distributed controller that can reduce electricity consumption by a requested number of megawatts, within a specific geographic zone, within 15 seconds — across a fleet of 10 million connected endpoints — while satisfying a set of hard constraints.

Constraints You Must Respect

User preferences and consent

  • Each household has a contractual policy: acceptable temperature swing, minimum EV battery level by a given deadline, and the right to opt out (at a financial penalty).

Protected loads

  • Certain circuits must never be curtailed under any circumstances: home medical equipment, refrigeration, and municipal infrastructure like water pumps.

Device physics

  • Devices have ramp-down times. HVAC compressors have minimum-off durations that must be respected to avoid hardware damage. Solar and wind output fluctuates.

Fairness

  • No household should bear a disproportionate share of curtailment events over time. Disruption must be distributed equitably.

Local autonomy

  • Edge gateways must behave safely during internet outages using cached policies, without needing a round-trip to the cloud.

Scale and Performance

  • 10 million endpoints, each reporting telemetry every 10 seconds — roughly 1 million events per second at ingestion.
  • Commands must reach devices within 5 seconds of a trigger.
  • The system must achieve at least 95% of the requested load reduction even when some devices are unreachable or non-responsive.
  • No single point of failure anywhere in the stack.
  • All curtailment decisions must be logged in a tamper-evident way for billing adjustments and regulatory audits.

What to Cover

  1. Architecture — How data flows from device to dispatch, what the regional control topology looks like, and how you avoid global bottlenecks.
  2. Data model and API — Schema for device capabilities, user policies, and the dispatch interface.
  3. Allocation engine — The algorithm and data structures that select devices under the latency budget.
  4. Failure handling and trade-offs — Non-responsive devices, network splits, malicious or stale telemetry, and over- or under-shedding.

Hints

Hint 1

You can't run an optimizer over millions of devices at emergency time — think about what work can be done continuously in the background so that dispatch is just a fast read from precomputed state.

Hint 2

Devices that must never be shed (medical, critical infrastructure) are best excluded from the selectable pool by construction, not filtered at runtime. How does that simplify your allocation logic?

Hint 3

Achieving 95% of a target when some devices won't respond is a statistics problem. If each device has a known historical compliance rate, how much do you need to overbook to hit the confidence bound?