KatInterview

Fleet Command Dispatch and Telemetry Reconciliation at Scale

System DesignModel answer
HardModel answerSystem Designdistributed-systemsedge-computingidempotency

Last updated

Design a durable, idempotent command pipeline and telemetry reconciliation engine for five million intermittently connected edge devices.

Background

You work on the infrastructure team for a platform that manages a large fleet of edge devices — industrial controllers, remote inference nodes, and sensor hubs deployed in the field. Operators and automated systems need to send imperative commands to devices: run a self-test, swap a model artifact, restart a service, issue an emergency halt. The catch: devices go offline for hours or days at a time, reconnect over high-latency links, and report back with duplicated or out-of-order telemetry.

What You Need to Design

Design the full end-to-end pipeline that handles:

  1. Accepting and dispatching commands to devices or groups of devices
  2. Tracking exactly where each command is in its lifecycle, per device
  3. Reconciling incoming telemetry against server-side state
  4. Keeping the system safe when commands are cancelled, devices reconnect in a storm, or the network partitions mid-execution

Constraints and Scale

  • Fleet size: 5 million registered devices; up to 1 million concurrently online
  • Telemetry volume: ~33,000 events/sec at steady state, bursting to 200,000 events/sec during mass reconnects (~1 KB per event)
  • Command throughput: up to 10,000 dispatch requests/sec; a single tag-targeted command can fan out to millions of individual device queues
  • Targeting: commands can address explicit device IDs or dynamic tag expressions (e.g., region=us-east, model=v2-arm)
  • Scheduling: commands carry a not_before timestamp, an expires_at TTL, and a priority
  • Lifecycle states: QUEUED → DISPATCHED → ACKNOWLEDGED → EXECUTING → COMPLETED | FAILED | EXPIRED
  • Durability: zero command loss for any command accepted within its TTL
  • Idempotency: a device must never execute the same non-idempotent action twice, even if the command is redelivered

Deliverables

Address all four areas in your answer:

  1. API and data model — command submission, cancellation, status query, device-side protocol, and the schema for commands, per-device queues, and execution logs
  2. System architecture — the major components and how they connect: submission path, fan-out, gateway layer, telemetry ingestion, and reconciliation
  3. Reconciliation strategy — how late, duplicate, and out-of-order telemetry is handled; how clock drift and server-inferred state interact with observed device reports
  4. Failure modes and safety — network partitions mid-execution, reconnect storms, zombie/stale command execution, and cancellation fencing

Hints

Hint 1

Start by separating imperative commands (run diagnostic, reboot) from declarative desired-state updates (active model = v2.3). They have very different idempotency and retry semantics, and conflating them leads to subtle bugs.

Hint 2

Exactly-once delivery is impossible over a lossy network. The realistic goal is at-least-once delivery paired with device-side deduplication, giving exactly-once effect. Make sure your design draws that boundary clearly.

Hint 3

Order telemetry events by a device-managed monotonic sequence number rather than wall-clock time. This makes clock drift irrelevant to correctness and gives you a clean forward-only state lattice for lifecycle transitions.