System Design Interview

Wrap Up

Wrap up 2 min readLesson 4 of 4

In this chapter, we have presented a design for building large-scale email servers. We started by gathering requirements and doing some back-of-the-envelope calculations to get a good idea of the scale. In the high-level design, we discussed how traditional email servers were designed and why they cannot satisfy modern use cases. We also discussed email APIs and high-level designs for sending and receiving flows. Finally, we dived deep into metadata database design, email deliverability, search, and scalability.

If there is extra time at the end of the interview, here are a few additional talking points:

  • Fault tolerance. Many parts of the system can fail, and you can talk about how to handle node failures, network issues, event delays, etc.

  • Compliance. Email service works all around the world and there are legal regulations to comply with. For instance, we need to handle and store personally identifiable information (PII) from Europe in a way that complies with General Data Protection Regulation (GDPR) 29. Legal intercept is another typical feature in this area 30.

  • Security. Email security is important because emails contain sensitive information. Gmail provides safety features such as phishing protections, safe browsing, proactive alerts, account safety, confidential mode, and email encryption 31.

  • Optimizations. Sometimes, the same email is sent to multiple recipients, and the same email attachment is stored several times in the object store (S3) in the group emails. One optimization we could do is to check the existence of the attachment in storage, before performing the expensive save operation.

Congratulations on getting this far! Now give yourself a pat on the back. Good job!

Chapter summary

Reference Materials

  1. Number of Active Gmail Users: https://financesonline.com/number-of-active-gmail-users/
  2. Outlook: https://en.wikipedia.org/wiki/Outlook.com
  3. How Many Emails Are Sent Per Day in 2021?: https://review42.com/resources/how-many-emails-are-sent-per-day/
  4. RFC 1939 - Post Office Protocol - Version 3: http://www.faqs.org/rfcs/rfc1939.html
  5. ActiveSync: https://en.wikipedia.org/wiki/ActiveSync
  6. Email attachment: https://en.wikipedia.org/wiki/Email_attachment
  7. MIME: https://en.wikipedia.org/wiki/MIME
  8. Threading: https://en.wikipedia.org/wiki/Conversation_threading
  9. IMAP LIST Extension for Special-Use Mailboxes: https://datatracker.ietf.org/doc/html/rfc6154
  10. Apache James: https://james.apache.org/
  11. A JSON Meta Application Protocol (JMAP) Subprotocol for WebSocket: https://datatracker.ietf.org/doc/rfc8887/
  12. Cassandra Limitations: https://cwiki.apache.org/confluence/display/CASSANDRA2/CassandraLimitations
  13. Inverted index: https://en.wikipedia.org/wiki/Inverted_index
  14. Exponential backoff: https://en.wikipedia.org/wiki/Exponential_backoff
  15. QQ Email System Optimization (in Chinese): https://www.slideshare.net/areyouok/06-qq-5431919
  16. IOPS: https://en.wikipedia.org/wiki/IOPS
  17. UUID and timeuuid types: https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/uuid_type_r.html
  18. Message threading: https://www.jwz.org/doc/threading.html
  19. Global spam volume: https://www.statista.com/statistics/420391/spam-email-traffic-share/
  20. Warming up dedicated IP addresses: https://docs.aws.amazon.com/ses/latest/dg/dedicated-ip-warming.html
  21. 2018 Data Breach Investigations Report: https://enterprise.verizon.com/resources/reports/DBIR_2018_Report.pdf
  22. Sender Policy Framework: https://en.wikipedia.org/wiki/Sender_Policy_Framework
  23. DomainKeys Identified Mail: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail
  24. Domain-based Message Authentication, Reporting & Conformance: https://dmarc.org/
  25. DB-Engines Ranking of Search Engines: https://db-engines.com/en/ranking/search+engine
  26. Refactoring practice: build full-text search of QQ mailbox based on Tencent Cloud Elasticsearch: https://www.programmersought.com/article/24097547237/
  27. Log-structured merge-tree: https://en.wikipedia.org/wiki/Log-structured_merge-tree
  28. Microsoft Exchange Conference 2014 Search in Exchange: https://www.youtube.com/watch?v=5EXGCSzzQak&t=2173s
  29. General Data Protection Regulation: https://en.wikipedia.org/wiki/General_Data_Protection_Regulation
  30. Lawful interception: https://en.wikipedia.org/wiki/Lawful_interception
  31. Email safety: https://safety.google/intl/en_us/gmail/

Finished reading?

Mark it complete to track your progress.