Design Problem- Structural analysis- Email Service

Santosh Rangarajan
2 min readNov 7, 2020

This is second article in series on Design problem. You can read first one here

In post we discuss about How to Design Email Service

  1. Understanding the problem/Key concepts needed to solve it

In this case we are building web scale email functionality/service/product. Below are key concepts/considerations which one should consider

  • smtp protocol- simple mail transmission protocol, how emails are sent and received. Usually this is achieved via smtp server. To start with you can download any existing open source email servers or use providers like - gmail, aws, mail-chimp etc

Below diagram represents workflow how smtp server works

smtp protocol
  • web application considerations- front-end, backend, database, number of servers

2. Understand the behaviour of Whole system/ List Requirements

  • registration service
  • email service - send and receive emails
  • notification when new email comes
  • clients supported - web and mobile
  • security- how to ensure email password is safe

3. High Level Design

email service

4. Detailed Design

Backend consists of multiple services/interfaces

  • registration
  • notification
  • search
  • send email
  • spam marking/checking

Each of above represents functionality which can be grouped in some logical basis into 1 or more service. Example below

  • MetaMailService- registration, notification, search.
  • EmailService - send email functionality, spam checking

Send email workflow

  1. Load Balancer- to manage load. it can send request to multiple front ends. it can be basis round robin or subsetting or hash ring based selection algorithm
  2. Multiple Front end and Backends are available to manage requests and absorb load
  3. Backend services support functionalities
  4. From service, request goes to queue to regulate the flow
  5. From queue its sent to smtp server and db service
  6. There is also spam service which facilitates in marking/identifying spam emails
  7. Smtp Server- This is used to communicate to other mail servers via internet. This can be any open source server which can be set up in house or it can be any of existing mail servers like — gmail, aws,mailchimp etc

--

--

Santosh Rangarajan

Software Engineer. Interests include — Distributed Systems, Data Storage , Programming languages