Katkat

Design a large-scale temperature sensor system

AmazonSoftware Engineer · Technical Screen

Last updated

This question tests your ability to design a high-throughput data ingestion pipeline and storage architecture for a fleet of IoT sensors, focusing on write-heavy scalability and time-series query performance.

Problem Statement

You are tasked with designing a system to collect temperature data from 10 million IoT sensors globally. Each sensor sends a temperature reading every 10 seconds. The system must support real-time monitoring of current readings and historical trend analysis for any sensor over the past 30 days.

Functional Requirements

  1. Ingestion: Handle a sustained write load of 1 million events per second.
  2. Retrieval: Provide an API to fetch the current temperature for a specific device.
  3. Analytics: Provide an API to query the average, min, and max temperature for a specific device within a given time range.

Non-Functional Requirements

  1. Scalability: The system should handle future growth without requiring a full redesign.
  2. Latency: Current temperature lookups should be sub-100ms.
  3. Availability: The system must remain available even if a regional data center fails.

Deliverables

  1. A high-level architecture diagram (described in text).
  2. API specifications for data ingestion and data retrieval.
  3. A data model and choice of database technologies.
  4. Strategy for handling high write volume and cold data archiving.

Example Constraints

  • Each event: {sensor_id: string, timestamp: long, temperature: float}
  • Total data storage volume calculation is expected as part of your design.

Hints

Hint 1

Consider using a distributed message queue to decouple ingestion from storage and prevent data loss during traffic spikes.

Hint 2

Time-series databases are optimized for this workload; consider how partitioning data by sensor_id or time-bucket helps with both write throughput and query performance.

Hint 3

For massive scale, think about how you might implement a hot/cold storage strategy where recent data stays in memory/fast SSDs while older data is moved to cheaper object storage.

Follow-up questions

  • How would you modify the system to provide real-time alerts if a sensor reports a temperature exceeding a specific threshold?
  • If we add a requirement to aggregate global average temperature across all sensors every minute, how would that change your architecture?
  • How would you ensure data integrity and handle out-of-order event arrivals from sensors experiencing intermittent network connectivity?