hard microsoft google · part of Practice Questions · Senior SWE Roadmap

Requirements to clarify

  • Functional: send/receive email, store mailboxes, search mail, filter spam.
  • Non-functional: mailboxes can grow huge over years, delivery must be reliable (retry on temporary failure), spam filtering must run without materially delaying legitimate mail.

Core components

  • SMTP handling: inbound mail accepted via SMTP servers, which queue it for processing rather than handling everything synchronously.
  • Spam/virus filtering pipeline: incoming mail passes through a filtering stage (often async) before landing in the inbox — a classic queue-based pipeline stage.
  • Storage: mailbox contents (often large attachments) split between metadata (in a DB, indexed for search) and the actual message/attachment bodies (in object storage) — similar pattern to the File Storage design.
  • Search indexing: a separate full-text index (e.g., inverted index) built asynchronously from stored mail, since search-while-you-type demands are very different from the write path.
  • Delivery retries: outbound mail to other servers uses retry with backoff for temporary failures (4xx SMTP responses), distinct from permanent failures (5xx, bounce immediately).

Key tradeoffs

  • Running spam filtering synchronously (delays delivery, more accurate with more time) vs asynchronously (fast delivery, filter/flag shortly after) — most systems do a fast synchronous check plus a more thorough async pass.

Approach / Notes