📝 Problem Description
Design an email system like Gmail. Handle sending and receiving emails via SMTP, store millions of emails per user, provide fast search, spam filtering, and real-time notifications.
👤 Use Cases
1.
User wants to sends email so that email delivered to recipient
2.
User wants to receives email so that appears in inbox
3.
User wants to searches emails so that finds matching messages
4.
System wants to receives spam so that filters to spam folder
✅ Functional Requirements
- •Send emails (SMTP)
- •Receive emails (IMAP/POP3)
- •Folders and labels
- •Full-text search
- •Spam and phishing detection
- •Attachments (up to 25MB)
- •Threaded conversations
⚡ Non-Functional Requirements
- •Deliver 99.9% of emails within 5 seconds
- •Search < 1 second
- •Store 15GB per user
- •99.99% availability
⚠️ Constraints & Assumptions
- •Must handle spam (90% of email is spam)
- •Email protocols are complex (MIME, encoding)
- •Deliverability requires good reputation
📊 Capacity Estimation
👥 Users
1B users, 300B emails/day
💾 Storage
15PB (15GB × 1B users)
⚡ QPS
Send: 3M/sec, Receive: 3M/sec
📐 Assumptions
- • 1B users
- • 300B emails per day
- • Average email: 50KB
- • 90% spam (filtered before storage)
💡 Key Concepts
CRITICAL
SMTP Protocol
Send email via port 25/587. SPF/DKIM/DMARC for authentication.
CRITICAL
Spam Filtering
ML model + rules to classify spam. Block 90%+ of incoming mail.
HIGH
Email Threading
Group related emails by In-Reply-To and References headers.
HIGH
Full-text Search
Index email body and attachments for fast search.
💡 Interview Tips
- 💡Start with the SMTP protocol basics
- 💡Discuss spam filtering strategies
- 💡Emphasize the importance of deliverability
- 💡Be prepared to discuss email threading algorithms
- 💡Know the difference between POP3 and IMAP
- 💡Understand the email storage and indexing