System should retrieve current weather data for specified locations.
Users can specify a location and receive the latest weather data.
Weather details should include temperature, humidity, weather conditions, etc.
The user can specify units of measurement.
The system has support for real-time updates of data.
Non-Functional Requirements:
99.9% uptime/availability
<2s non-cached requests, <500ms cached requests
10k concurrent users, can accommodate demand spikes due to severe weather events.
Weather data is consistent and updated regularly
API Design
GET /weather/?location=<location>&units=<metric>
POST /weather/?location=<location>
High-Level Design
WeatherService:
Weather data per location
Populates data with external APIs
Responsible for converting data into unified format
Real-Time Updates:
WebSockets in combination with publisher/subscriber pattern.
Client's open a WebSocket connection and subscribe to updates for a given location.
When the server receives weather updates for a given location, it pushes the update to all current subscribers of that location. (Weather updates can also be pushed on a scheduled basis.
Detailed Component Design
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.