Problem statement
Design a high-throughput read service that turns coordinates into human-readable addresses and place components, backed by an expensive geocoding engine and fronted by a multi-tier cache that exploits spatial locality.
Operating context. Callers send a coordinate and want the nearest address (street, locality, region, postal code). The underlying geocoding engine is accurate but slow and capacity-limited, so most traffic must be served from cache. Nearby queries should share a cached answer, which means snapping coordinates to a cell before keying the cache. Reads dominate; the same dense areas are queried constantly while a long tail of rural coordinates is queried rarely. Map data behind the geocoder is refreshed periodically and stale answers must eventually be corrected.
Out of scope. The geocoding engine's address-matching algorithm and dataset curation, forward geocoding (address→coordinate), place autocomplete, and routing. Assume the geocoder is a slow, rate-limited dependency you call on a miss.
What to produce. A high-level architecture covering: the cache-key design (coordinate quantization to a geocell) and the precision-versus-accuracy trade-off; the multi-tier cache (edge, regional, shared store) and promotion between tiers; the cache-miss path to the geocoder with stampede protection; warming/precomputation for dense areas; invalidation when map data updates; and how the service stays up and bounded when the geocoder is down or overloaded. Sketch the components and the flow of a hit and a miss; we will probe specifics in checkpoints.
Functional requirements
- Return the nearest address and place components for a (lat, lng) query.
- Snap the coordinate to a cache cell so nearby queries reuse one cached result.
- On a cache miss, call the geocoding engine and populate the cache.
- Serve a batch reverse-geocode endpoint for many coordinates at once.
- Invalidate cached entries for a region when its underlying map data changes.
Non-functional requirements
- Serve 300,000 lookups/sec; cache-hit p99 < 50 ms, cache-miss p99 < 400 ms.
- Achieve a >95% cache hit rate at steady state via spatial quantization.
- Protect the rate-limited geocoder from stampedes on cold or newly popular cells.
- 99.95% availability of the read path; serve stale-but-valid on a geocoder outage.
- Bound cache footprint: hot cells in memory, the long tail in a shared store.
- Batch endpoint returns up to 1,000 coordinates within 300 ms.
Topics
- System Design HLD
- Geo Geocoding
- Data Cache
- Scaling Read-Heavy
- Infra CDN