System Design Space
Knowledge graphSettings

Updated: March 25, 2026 at 4:52 AM

Google Maps / Proximity Service - geosearch

medium

Classic task: geo-index, nearby search, ranking, caching, regional sharding and latency-budget for a map.

Proximity search is hard because objects move, queries are local, and hot spots appear exactly where the system must answer fastest.

The case helps break down spatial indexing, write amplification from moving objects, radius search, geo partitioning, and coordinate freshness on the read path.

For interviews and design reviews, it is useful because it tests understanding of spatial indexes, locality, and the trade-offs between precision and latency.

Latency Budget

Each critical-path hop needs a clear latency budget and predictable fallback behavior.

Fanout Strategy

Push/pull/hybrid fanout choices determine scalability, consistency, and complexity.

Session State

Model presence, reconnect, ordering, and delivery semantics explicitly.

Graceful Degradation

Under peaks, preserve core functionality while reducing non-critical quality.

Source

System Design Interview

Classic Proximity Service as a separate geosearch pattern in product systems.

Open review

Proximity Service is a service that answers the question: “what is nearby” for a given point, radius and filters. In a Google Maps-level product, the architecture is built around two different contours: offline ingestion/indexing And online low-latency serving.

Requirements

Functional

  • The user moves the map and gets the nearest POI in the current viewport.
  • Search nearby by radius, category and text query.
  • Support for pagination and stable order of results when scrolling the map.
  • Separate API for tooltips (autocomplete) and API for point details.
  • Online update of data on the load/status of the point (optional).

Non-functional

Latency: p95 < 200ms

The map UI should not lag when pan/zooming.

Availability: 99.99%

Search should work even if some of the indexes are degraded.

Freshness: minutes, not hours

New/closed points should appear in the search results quickly.

Scale: millions of QPS

Geo-distributed traffic with clearly defined hot zones.

High-Level Architecture

Client Apps

Map UI, pan/zoom, nearby search

Geo API Gateway

Auth, throttling, routing by region

Proximity Serving

Geo index lookup + ranking + filters

Hot Cache

Redis/Memcached, geocells of popular zones

Geo Index Store

S2/H3/Geohash + posting lists by category

POI Metadata DB

Name, opening hours, rating, tags

The request is processed in two phases: candidate retrieval across adjacent cells, then ranking taking into account distance, relevance and business signals.

Interactive processing of a nearby request

Change the category and radius, then go through the pipeline step by step.

Example coordinate: 37.7793, -122.4192

Step 1 from 5

Geo API Gateway: query validation and normalization

The service validates the input parameters and sends the request to the nearest region.

Latency budget: 15-25ms
  • Checking the API key, limits and required parameters.
  • Normalization of lat/lng, radius and client locale.
  • Route-by-region to the nearest proximity serving cluster.
{
  "lat": 37.7793,
  "lng": -122.4192,
  "radius_m": 1500,
  "category": "cafe",
  "region": "us-west-1",
  "auth": "ok",
  "quota": "ok"
}

Selecting a spatial index

ApproachWhere is it especially useful?Compromises
GeohashEasy start and key-value storageUnevenness of cells and edge effects near borders.
S2Global maps and neat sphere geometryImplementation and debugging are more difficult.
H3Analytics, densities, heatmapsTransitioning between resolutions requires careful setup.
R-tree/QuadTreeHeavy spatial queries in the databaseMore expensive to update under high write load.

API and data model (simplified)

Main API

GET /v1/places/nearby?lat=37.78&lng=-122.41&radius=1500&category=cafe&limit=20

Response:
{
  "items": [
    { "place_id": "p123", "distance_m": 120, "score": 0.91 },
    { "place_id": "p889", "distance_m": 240, "score": 0.88 }
  ],
  "next_page_token": "..."
}

Index and metadata

  • geo_cell_index: cell_id -> place_ids
  • poi: place_id, name, category, coords, rating, business_hours
  • popularity_signals: recent clicks/check-ins/reviews
  • change_log: events for incremental re-index

Reliability and anti-patterns

What helps in production

  • Regional sharding by cell ranges + replication by zones.
  • Two-level cache: edge cache for popular zones + service cache.
  • Graceful degradation: fallback to a coarser index resolution.
  • Incremental reindex instead of a full index recalculation.

Common mistakes

  • Search only in one cell and forget about neighboring cells on the border of the radius.
  • Sort only by distance without quality score (rating, relevance, open/closed).
  • Do not separate the online serving index from the data preparation batch pipeline.
  • Make a global cache without regional sharding and without stampede protection.
  • Forget about deduplicating POIs from different data providers.

Reference

S2 Geometry

A practical tool for cell-based spatial indexing on a sphere.

Open

Related chapters

Enable tracking in Settings