Design a Weather App
Design the backend of a weather app. When someone opens the app, or a home-screen widget refreshes, it asks for the forecast at the phone’s location: current conditions, the next 48 hours and the next 10 days. People can also search for a city, save a few places, and get a push notification when a severe weather warning covers one of them. The forecasts come from an outside weather data provider.
The app has 30 million daily users, and widgets refresh every 30 minutes, so the backend sees about 50,000 requests a second at the morning peak and up to 200,000 when a big storm sends everyone to their phones. The data itself changes slowly, every 10 to 60 minutes, and the provider charges per call and caps us at 2,000 calls a second. The hard parts are turning millions of slightly different GPS positions into answers that can be cached, never letting a traffic spike reach the provider, and pushing a warning to 2 million phones in a city within a minute.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Where do forecasts come from?
- 2How precise must a location be?
- 3How fresh must data be?
- 4What is in a response?
- 5Do we need accounts?
- 6Severe weather alerts?
- 7Units and languages?
- 8Radar maps and history?
How to spend the 45 minutes
- 5minPart 1: Requirements: precision, freshness, alerts
- 5minPart 2: Estimates: peaks, cells, provider cap
- 5minPart 3: API and data model
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Cells, ingest, caching and alerts