System Design: Real-Time Typeahead/Autocomplete
Context
Design a real-time typeahead/autocomplete service for a consumer-facing web and mobile application. Users see suggestion updates on each keystroke. Assume global traffic, multiple locales, and both anonymous and signed-in users.
Requirements
Design the system and cover:
-
API design and request/response schemas
-
Data modeling and indexing (e.g., prefix trees, FST, inverted indexes)
-
Ranking signals and personalization
-
Latency targets and budgets (e.g., P95 < 100 ms)
-
Caching layers (edge, in-memory, distributed)
-
Scalability and capacity planning
-
Freshness and backfill pipelines (batch + streaming)
-
A/B experimentation hooks and telemetry
-
Failure handling and graceful degradation
State assumptions where needed and justify trade-offs.