SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 36
Design a weather app
A mobile and web app shows current conditions, an hourly forecast and a 10-day outlook for where you are and for places you saved, and warns you when severe weather is coming. The forecasts come from paid upstream weather providers; the app does no meteorology of its own.
Requirements
- Show current conditions, a 48-hour hourly forecast and a 10-day daily forecast for the device location or a saved place.
- Users save up to 10 places; the app opens instantly with the last data it had, even with no network.
- Push severe-weather alerts (tornado, flash flood) to devices whose saved places or recent location fall inside the alert area.
- Keep working, possibly with older data, when the primary provider is down.
Constraints and assumptions
- 20M monthly users, 4M daily; peak 30,000 forecast reads/s during morning hours and during big storms.
- The primary provider bills per call and allows at most 500 calls/s. Its forecasts update about hourly; current conditions about every 10 minutes. A secondary provider is available at higher cost.
- Official alerts arrive as polygons from a government feed: about 5,000 a day, up to 300 in a bad hour. A tornado warning must reach phones within 60 seconds of arrival.
- One coverage region of about 10M km² (roughly a large country); phones are often on slow or flaky networks.
Out of scope for the first sketch
Radar and map tiles · User accounts (a device id is enough) · Historical climate data · Ads
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a weather app
Finish your first sketch before answering these. Cross out freely.
- You have 30,000 reads/s and a provider that allows 500 calls/s. How do you key your cache so nearby users share entries?
- The primary provider is down for 20 minutes. What do users see, and what does the backend do?
- A tornado warning polygon covers 400,000 devices. Walk through how each of them gets a push within a minute, exactly once.
- The app opens in a subway with no signal. What does it show, and how does the user know how old it is?
- A hurricane makes one coastal city 50 times busier than normal, and everyone refreshes at once. What breaks first?
Compare afterwards: worked approaches and reading at sketchbook /questions/weather-app/review