Design Facebook Search with Typeahead

Quick Overview

Design a search system with typeahead autocomplete for Facebook. Cover indexing strategies, ranking algorithms, query processing, and how to suggest top 10 results based on character input, frequency, and social signals.

Meta
System Design
Software Engineer
Meta
Software Engineer
Onsite
System Design
Hard

0


Design a search system with typeahead autocomplete for Facebook. Cover indexing strategies, ranking algorithms, query processing, and how to suggest top 10 results based on character input, frequency, and social signals.

Facebook search typeahead is a hard Meta onsite question because results mix people, pages and groups and must be ranked by each user's social graph within a tight latency budget. The interviewer checks prefix indexing across entity types, how social signals feed ranking, and how fresh entities reach the index quickly.

What the Interviewer Expects
  • Clarify entity types, result count, latency target and personalization scope
  • Build prefix indexes per entity type, sharded, plus a per-user index of close connections
  • Use two-phase retrieval: fast candidate fetch, then ranking with social features
  • Combine global popularity with personal signals such as friendship and past clicks
  • Keep the index fresh for new users, renamed pages and new groups
  • Respect privacy so blocked or hidden entities never appear
Key Topics to Cover
Typeahead indexing
Social graph ranking
Prefix search
Sharding and fan-out
Personalization
Privacy filtering
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How do you rank a friend-of-friend above a celebrity with the same name prefix?
  • How would you support non-Latin scripts and transliteration?
  • How do you keep p99 latency low when fanning out to many index shards?
  • How would you evaluate a new ranking model offline and online?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Functional Requirements:

  1. Typeahead Autocomplete: As users type in the search bar, suggestions should appear in real-time, displaying up to 10 results.
  2. Searchable Entities: Support se...
Capacity Estimation
  1. User Base: Facebook has approximately 2.89 billion monthly active users.
  2. Search Queries: Assuming each user performs an average of 5 searches per day, that leads to:
    • Total searches ...

Submit Your Answer
Markdown supported