Design a large-scale temperature sensor system
AmazonSoftware Engineer · Technical ScreenLast 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
- Ingestion: Handle a sustained write load of 1 million events per second.
- Retrieval: Provide an API to fetch the current temperature for a specific device.
- Analytics: Provide an API to query the average, min, and max temperature for a specific device within a given time range.
Non-Functional Requirements
- Scalability: The system should handle future growth without requiring a full redesign.
- Latency: Current temperature lookups should be sub-100ms.
- Availability: The system must remain available even if a regional data center fails.
Deliverables
- A high-level architecture diagram (described in text).
- API specifications for data ingestion and data retrieval.
- A data model and choice of database technologies.
- 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?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.