Email Service (Gmail)
Requirements: send/receive email (SMTP), store mailboxes, search, labels/threads, spam filtering, attachments; billions of users, mostly reads.
outbound: client -> web/API -> send queue -> SMTP outgoing servers -> internet (DKIM signing, retries)
inbound: internet -> SMTP incoming -> spam/virus filtering -> mailbox svc
| metadata (Bigtable/Cassandra: user_id, folder, msg_id)
| bodies + attachments -> object store (dedupe by hash)
| search index (per-user inverted index)
real-time sync to clients via push (WebSocket / IMAP IDLE / push notifications)
Deep dives: shard everything by user_id (mailbox is per user, no cross-user queries); per-user search index; threading by Message-ID/In-Reply-To headers; spam = ML classifier + reputation (SPF/DKIM/DMARC); large attachments stored once and referenced; eventual consistency across devices with sync tokens.