Design Per-User Mailbox Search for Gmail
Last updated: November 29, 2026
Quick Overview
Design full-text search over each user's own mailbox in Gmail, returning results in under a second for mailboxes holding hundreds of thousands of messages, with operators like from:, has:attachment, and date ranges.
0
0
0 solved
Design full-text search over each user's own mailbox in Gmail, returning results in under a second for mailboxes holding hundreds of thousands of messages, with operators like from:, has:attachment, and date ranges.
Unlike web search, Gmail search is billions of small private indexes, which changes every design choice. Interviewers check per-user index partitioning, freshness for just-arrived mail, and keeping search isolated for privacy.
What the Interviewer Expects
- Recognizes the per-user index shape versus a global index
- Designs indexing on mail arrival with freshness
- Supports structured operators alongside text
- Plans storage for cold versus active users
- Ranks results sensibly (recency plus relevance)
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How fast can a just-received email be searchable?
- How do you search attachment contents?
- How do you handle a 50 GB mailbox?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: keyword search over subject, body, sender, recipients, and attachment text; operators (from:, to:, label:, has:attachment, before:/after:, is:unread); results sorted by relevance or da...
High-Level Design
- Mail ingest stores the message in the user's mailbox store (sharded by user id) and publishes an indexing event.
- Indexer tokenizes fields, extracts attachment text asynchronously, and up...