Design typeahead that returns ranked suggestions in milliseconds at global scale. The system must ingest query logs safely, handle viral prefixes, and blend popularity with personalization.
Functional requirements
- Prefix suggestions over huge corpora with ranking
- Personalization from recent and long-term user signals
- Trending queries promoted quickly from streaming logs
- Spell correction, synonyms, and locale-aware tokenization
- Safety and policy filters for sensitive or brand-risk queries
Non-functional requirements
- Sub-100ms P99 at the edge for common prefixes
- Horizontal scale for index shards and ingest pipelines
- Resilience to flash crowds via caching, shedding, and negative caches
- Deep visibility into hit ratio, ranker timeouts, and index lag