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.

Google
System Design
Software Engineer
Google
November 29, 2026
Software Engineer
System Design Round
System Design
Medium

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
inverted index
per-user sharding
incremental indexing
tiered storage
privacy isolation
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 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 Problems
Sample 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
  1. Mail ingest stores the message in the user's mailbox store (sharded by user id) and publishes an indexing event.
  2. Indexer tokenizes fields, extracts attachment text asynchronously, and up...

Submit Your Answer
Markdown supported