System Design Interview: Designing a Weather Forecast Service
3 views
"Design a weather service that shows current conditions and forecasts for any location" is a good system design interview question because most traffic is reads, data arrives from external sources on a schedule, and the right caching strategy does most of the work.
1. Requirements
Functional: current conditions and hourly and daily forecasts for a location given by coordinates, city name or postal code; severe weather alerts pushed to subscribed users; a public API for partner apps. Non-functional: very high read volume with sharp spikes during storms, responses under 200 ms, data no more than about 10 to 15 minutes old, and high availability.
2. Data sources and ingestion
Weather data comes from national meteorological agencies, commercial providers, radar and satellite feeds, and sometimes sensor networks. Forecast model output usually updates every few hours, observations every few minutes. An ingestion layer pulls or receives these feeds, validates and normalizes units and formats, and writes them to storage. Keep raw files in object storage for reprocessing.
3. Spatial model
Forecasts are produced on grids. Map every request location to a grid cell or to the nearest station, using a geospatial index (geohash or a fixed grid), then interpolate where needed. Because millions of users map to a much smaller number of cells, you can precompute and cache results per cell rather than per user.
4. Storage
- Time-series store for observations and forecasts keyed by (cell_id, timestamp).
- A small relational database for locations, place names and user subscriptions.
- A geocoding service to turn "Springfield" into coordinates, with disambiguation for duplicate names.
5. Read path and caching
Precompute a compact forecast document per cell after each model update and store it in a distributed cache and on a CDN with a short time-to-live matching the update frequency. API servers translate the location to a cell, read the document from the cache, and fall back to the time-series store on a miss. During a hurricane, traffic to a few cells can jump a hundred times; the CDN absorbs most of it.
6. Alerts
Alerts arrive from official sources as polygons. Match each alert polygon against the cells and the users subscribed to those cells, then fan out push notifications through a queue so a big alert does not overwhelm the system. Deduplicate so a user is not notified repeatedly for the same alert.
7. Public API
API keys, rate limits per plan, versioned endpoints, and usage metering for billing.
8. Reliability
Multiple data providers for failover, stale-but-labeled data if a source fails ("updated 40 minutes ago"), multi-region deployment, and monitoring of feed freshness with alerts when an expected update is late.
9. Trade-offs to discuss
Grid resolution versus storage cost, cache TTL versus freshness, interpolating between grid points versus nearest station, and push versus pull for alerts.
A strong answer moves from requirements to ingestion, the spatial model, caching and alerts. If you want support while the interviewer probes further, Linkjob AI (https://linkjob.ai) gives real-time help during job interviews and technical interviews, including system design rounds.