KatInterview

Design a Real-Time Thermal Telemetry & Ingestion System

System DesignModel answer
MediumModel answerSystem Designsystem-designiottime-series

Last updated

Design an IoT telemetry platform ingesting half a million sensor readings per second, featuring low-latency current state queries, delayed data processing, and downsampled long-term storage.

Scenario

A global cold-chain logistics network requires continuous temperature monitoring across millions of refrigeration units, transit hubs, and fleet vehicles. Exposure to temperature anomalies can compromise sensitive cargo.

You need to design a reliable, scalable system that ingests high-throughput temperature sensor data, calculates current asset state, triggers real-time alerts, and maintains both raw and aggregated history.

System Characteristics & Constraints

  • Sensor Population: 5,000,000 active temperature sensors.
  • Reporting Frequency: Every 10 seconds per device.
  • Ingestion Scale: ~500,000 events/sec baseline, with burst capacity up to 1,000,000 events/sec (e.g., when mobile assets reconnect after losing network signal).
  • Latency Targets:
    • P99 latency for fetching current asset status must be under 50 ms.
    • Delay from device ingestion to safety breach alerting must be under 5 seconds.
  • Data Lifecycle Requirements:
    • Raw event retention: 30 days.
    • Aggregated hourly/daily summary retention: 2 years.

Requirements

Functional

  1. Device Connection & Ingestion: Securely collect readings over standard lightweight protocols (MQTT, HTTP/2, gRPC over TLS).
  2. Event Handling: Support device generation timestamps as well as server receipt timestamps. Deduplicate redundant messages and process out-of-order data gracefully.
  3. Current State Projection: Provide real-time queries for the latest recorded temperature and operational status for any sensor, asset, or facility.
  4. Time-Series Storage & Rollups: Store detailed event data and continuously compute downsampled aggregates (min, max, mean per hour/day), supporting backfilled historical uploads.
  5. Rules Engine & Threshold Alerts: Detect out-of-bounds conditions (e.g., temperature exceeds 4°C for more than 15 consecutive minutes) and emit notifications.

Non-Functional

  • Availability & Resilience: 99.99% availability for the write path. Vehicles operating offline must store readings locally and upload batch payloads without starving live streams.
  • Scalability: Horizontal scaling for API gateways, message queues, stateful processors, and storage layers.

What to Cover

  • Capacity Estimation: Traffic volume, storage size, and memory requirements.
  • System Architecture: End-to-end design from edge gateways to ingestion, streaming components, and database tiers.
  • Data Schemas & Storage Strategy: Payloads, ingestion protocols, current-state cache structure, raw time-series storage, and aggregate schemas.
  • Handling Out-of-Order & Delayed Data: Deduplication strategies, watermarking rules, avoiding stale cache overwrites, and historical recomputation pipelines.
  • Retention & Downsampling: Automated rollups and efficient lifecycle management for expiring raw metrics.

Hints

Hint 1

Establish clear estimates for write throughput vs query memory before selecting data stores.

Hint 2

Distinguish between live streaming ingest and backfilled bulk ingest from reconnected vehicles by splitting Kafka topics.

Hint 3

Use atomic versioning or timestamp comparisons (e.g., Lua scripts in Redis) to prevent old backfill data from corrupting the current-state projection.