SD-36 · Back to the write-up
Design a Weather App
Snap positions to 5 km cells, ingest the provider’s feed on a schedule, and let a CDN and a cache answer almost every request.
Follow a request
Open the app · edge hit
Open the app · miss
A new model run
A severe weather warning
Provider outage
Phones
Edge
Services
Data + provider
Mobile appSnaps to a cell
Push servicesApple, Google
CDNCell URLs
Load balancerSpreads traffic
Ingest workersEvery run
Forecast APIStateless
Forecast cacheHot cells
Alert workersFan-out
Weather providerBulk feed
Forecast storeBy cell
SubscriptionsCell → devices
The numbers, at a glance
1 store read99 from CDN or cache
50,000Every request
2,500Every miss
2,000Provider cap
≈ 20Bulk ingest
4 GB hot cells64 GB node
A forecast request, in order
Edge and cache miss shown. On an edge hit, steps 2 to 9 disappear; on a cache hit, steps 5 and 6 do.
Mobile app
CDN
Load balancer
Forecast API
Forecast cache
Forecast store
1 GET /forecast/u0bmp
2 forward (collapsed)
3 route
4 GET u0bmp
5 miss
6 GET current version
7 2 KB forecast
8 SET until next update
9 200 + max-age
10 200
11 200 forecast
RequestResponseAsync, does not block
What a forecast is keyed by
The decision this question is really about.
?lat=48.85661&lon=2.35222
Cache hit ≈ 10%
Provider over its cap
+ Precise.− Every key unique; misses call the provider.
/forecast/city/2988507
Cache hit ≈ 99%
Mountain gets city weather
+ Few keys.− Wrong weather 40 km out.
/forecast/u09tv
CDN 80%Cache 95%
Store reads ≈ 1%
+ As precise as the data, 95% hits.− A cell shares one forecast.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Mobile app
App server
Weather provider
Mobile app
Load balancer
Forecast API × N
Forecast cacheWeather provider
Mobile app
Load balancer
Forecast API × NIngest workers
Forecast cacheForecast storeWeather provider
Mobile appPlace search
CDN
Load balancer
Forecast API × NIngest workersAlert workers
Forecast cacheForecast storeSubscriptions
Was this walkthrough useful?Your vote tells us what to improve next.