Real-Time Top-K POIs in Viewport: System Design
Context
Design a real-time system for a mobile map that continuously shows the top-K points of interest (POIs) within the user’s current viewport as they pan and zoom. The system must feel instant, remain stable while the viewport moves, and support personalization.
Requirements
Functional
-
Return top-K POIs for the current viewport rectangle and zoom level, with stable ordering during small pans/zooms.
-
Support filters (e.g., category, open-now), and pagination/infinite scroll for lists.
-
Deduplicate POIs across tiles and avoid flicker when moving.
-
Personalize ordering per user when available; provide sensible defaults for cold start.
Latency/SLOs
-
End-to-end p95 latency < 150 ms (from gesture end to POIs rendered), p99 < 250 ms.
-
Freshness: most POI attribute updates visible within 1–5 minutes; critical updates (closures) < 30 seconds.
-
Availability ≥ 99.9%.
Specify
-
Architecture across client, edge, and backend services.
-
Spatial indexing and tiling strategy (e.g., quadtree/S2, R-tree), cell covering, and range queries.
-
Candidate generation and cell unions.
-
Retrieval vs. re-ranking pipeline.
-
Caching (client/edge): tile-level and viewport-level.
-
Freshness and incremental updates.
-
Metrics (latency, quality, stability, freshness, cost).
-
When to use approximate nearest neighbor (ANN) for retrieval vs. learned models for ranking; decision criteria and hybrid approach.
-
Load shedding, pagination while panning, dedup across tiles, cold start, offline vs. online evaluation, and cost considerations.