SlideShare a Scribd company logo
1 of 23
Scheduled
delivery of a
large amount
of emails
By trial and error
Author
Roman Valihura
C
O
N
T
E
N
T
1. The mails delivery evolution
2. What our team is doing at Wise
3. Design scheduling architecture
problems
How to fetch emails in time
How to send emails in time
How to split emails between workers
4. Solutions conclusion
We are here
Usagesimplicity
Time
M A I L S D E L I V E R Y E V O L U T I O N
What our
team is
doing at
Wise
We are creating an
ESP (Email
Service Provider) that
provides convenient
Rest API for working
with large newsletters
and collect statistics
about how users
interact with your
emails
U S E C A S E D I A G R A M
R E G U L A R F L O W
I N 3 0 D A Y S
3-party
APP
I N   9 0 D A Y S
According to Wikipedia, a
presentation is the process
of presenting a topic to an
audience. It is typically a
demonstration,
introduction, lecture, or
speech meant to inform,
persuade, or build good will.
ESP API
Send E
mail
HTTP
Request
GrayBox
processing Sendemail to
user
Event
Storage
WE NEED A
scheduling
BETTER
CONTROL
Users can send emails
in advance and
monitor sending
process from their side
LESS LOAD
FOR API
You need to have less
servers and less
throughput if you have
more time
NO PERSONAL
CRON
You don't need
personal CRON for
delivery postponed
emails
U S E C A S E D I A G R A M
S C H E D U L I N G F L O W ( S T A G E 0 )
3-party
APP
I N   9 0 D A Y S
According to Wikipedia, a
presentation is the process
of presenting a topic to an
audience. It is typically a
demonstration,
introduction, lecture, or
speech meant to inform,
persuade, or build good will.
ESP API
Send
E
mail
HTTP
Request
Sendemail to
user
Event
Storage
Scheduling
Storage
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
M E E T T H E W O R K E R ( V 1 )
Bio
Name
Worker (v1)
Age
4 month
Sex
Male
Responsibility
Make query to data storage with certain interval
Send ready to send emails to target users 
How to find and fetch
emails in time?
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
M E E T T H E C L I C K H O U S E
Bio
Name
ClickHouse
Age
2 years 4 month
Sex
Undefined
Features
True column-oriented storage
Local and distributed joins
We use ClickHouse for events storage
Metrics (EC2 c5.large)
Read speed is 1.2 GB/s
Write speed is 50 to 200 MB/s 
Finding 335K scheduled emails on a
dataset with size 5M take 0.061 second
With network latency for transfer, we
able to fetch 3.5M emails per second
Summary
U S E C A S E D I A G R A M
S C H E D U L I N G F L O W ( S T A G E 1 )
3-party
APP
I N   9 0 D A Y S
According to Wikipedia, a
presentation is the process
of presenting a topic to an
audience. It is typically a
demonstration,
introduction, lecture, or
speech meant to inform,
persuade, or build good will.
ESP API
Send
E
mail
HTTP
Request
Sendemail to
user
Event
Storage
Clickhouse
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
N O B O D Y I S P E R F E C T
Bio
Name
Worker (v1)
Age
4 month
Sex
Male
Responsibility
Make query to data storage with certain interval
Send ready to send emails to target users 
Disadvantages
Works slow
How to send emails in
time when we have
limited throughput?
U S E C A S E D I A G R A M
S C H E D U L I N G F L O W ( S T A G E 2 )
3-party
APP
I N   9 0 D A Y S
According to Wikipedia, a
presentation is the process
of presenting a topic to an
audience. It is typically a
demonstration,
introduction, lecture, or
speech meant to inform,
persuade, or build good will.
ESP API
Send
E
mail
HTTP
Request
Sendemail to
user
Event
Storage
Scheduling
Storage
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
N O B O D Y I S P E R F E C T
Bio
Name
Worker (v1)
Age
4 month
Sex
Regular
Responsibility
Make query to data storage with certain interval
Send ready to send emails to target users 
Disadvantages
Works slow
Not team member
How to split emails
between workers without
duplicates?
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
M E E T T H E R A N G E R
Bio
Name
Ranger
Age
4 month
Sex
Male
Responsibility
The Ranger is responsible for making a range for
workers. Each range has unique properties that allow
worker decide which records need to fetch from a
database. Ready to send ranges creates internally.
Throughput
Working in pair with a ClickHouse as data storage, this
system is able to create about 700 ranges per second
with size 5000 emails.
U S E C A S E D I A G R A M
T H E R A N G E R F L O W
Scheduling
Storage
(ClickHouse)
Ranger
[2018-10-08T07:47:56.144Z, 3], [2018-10-08T07:47:56.144Z, 4] ...
dateFrom: Date('iso-format')
dateTo: Date('iso-format')
Workers
Messaging
Queue
Send email
to user
dateFrom: Date('iso-format')
dateTo: Date('iso-format')
S O U R C E : W I S E C H A R A C T E R S D A T A B A S E
M E E T T H E W O R K E R ( V 2 )
Bio
Name
Worker (v2)
Age
3 month
Sex
Male
Responsibility
Pull Message Queue with ranges
Fetch emails from ClickHouse by range payload
Send emails to target users
Advantages
Works
Team member
U S E C A S E D I A G R A M
T H E R A N G E R F L O W
Scheduling
Storage
(ClickHouse)
Ranger
[2018-10-08T07:47:56.144Z, 3], [2018-10-08T07:47:56.144Z, 4] ...
dateFrom: Date('iso-format')
dateTo: Date('iso-format')
Workers
Messaging
Queue
Send email
to user
dateFrom: Date('iso-format')
dateTo: Date('iso-format')
U S E C A S E D I A G R A M
S C H E D U L I N G F L O W ( S T A G E 3 )
I N 3 0 D A Y S
3-party
APP
ESP API
Send
E
mail
HTTP
Request
Send
email to
user
Scheduling
Storage
(ClickHouse)
Ranger
Workers
01
02
03
HOW TO FETCH EMAILS IN TIME?
We selected proper storage for that case.
With Сlickhouse, we can fetch 335K
records per second and filtering by ready
date take 0.1 seconds for 5M database set
(including network latency)
HOW SEND EMAILS IN TIME?
Obviously, we need a scaling for that case.
Using multiple workers we can reach such
throughput that we need.
HOW TO SPLIT EMAILS FOR WORKERS?
We created one more additional
component that doing ranges for our
workers and put them into a queue. Then
each worker fetches different range from
a queue.
Time
questions
for

More Related Content

Similar to Scheduled delivery of a large amount of emails

Web 2.0: Making Email a Useful Web App
Web 2.0: Making Email a Useful Web AppWeb 2.0: Making Email a Useful Web App
Web 2.0: Making Email a Useful Web AppAndy Denmark
 
Building Email Apps
Building Email AppsBuilding Email Apps
Building Email AppsAndy Denmark
 
Using Email to Send Push Notifications with Parse & Mailgun
Using Email to Send Push Notifications with Parse & MailgunUsing Email to Send Push Notifications with Parse & Mailgun
Using Email to Send Push Notifications with Parse & MailgunParseIt
 
S N A I L Final Presentation
S N A I L    Final  PresentationS N A I L    Final  Presentation
S N A I L Final PresentationQiong Wu
 
8 Ways To Improve Email Performance During End-of-Year.pdf
8 Ways To Improve Email Performance During End-of-Year.pdf8 Ways To Improve Email Performance During End-of-Year.pdf
8 Ways To Improve Email Performance During End-of-Year.pdfBloomerang
 
Top Essay Writing Websites
Top Essay Writing WebsitesTop Essay Writing Websites
Top Essay Writing WebsitesBeth Hernandez
 
Sales Email Hacks for Gmail and Salesforce
Sales Email Hacks for Gmail and SalesforceSales Email Hacks for Gmail and Salesforce
Sales Email Hacks for Gmail and SalesforceRingLead
 
Effective communication via email
Effective communication via emailEffective communication via email
Effective communication via emailMarianna Semenova
 
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...Women in Analytics Conference
 
Onesocialweb Presentation at OTA10
Onesocialweb Presentation at OTA10Onesocialweb Presentation at OTA10
Onesocialweb Presentation at OTA10dianacheng
 
Email and groupware
Email and groupwareEmail and groupware
Email and groupwareRoy Thomas
 
miniproject.ppt.pptx
miniproject.ppt.pptxminiproject.ppt.pptx
miniproject.ppt.pptxAnush90
 
Brains R Us Technology
Brains  R  Us  TechnologyBrains  R  Us  Technology
Brains R Us TechnologyMike Danielsen
 
2. DD-sample.docx
2. DD-sample.docx2. DD-sample.docx
2. DD-sample.docxdpgdpg
 
Nova Spivack - Semantic Web Talk
Nova Spivack - Semantic Web TalkNova Spivack - Semantic Web Talk
Nova Spivack - Semantic Web Talksyawal
 

Similar to Scheduled delivery of a large amount of emails (20)

Email
EmailEmail
Email
 
Web 2.0: Making Email a Useful Web App
Web 2.0: Making Email a Useful Web AppWeb 2.0: Making Email a Useful Web App
Web 2.0: Making Email a Useful Web App
 
Building Email Apps
Building Email AppsBuilding Email Apps
Building Email Apps
 
Using Email to Send Push Notifications with Parse & Mailgun
Using Email to Send Push Notifications with Parse & MailgunUsing Email to Send Push Notifications with Parse & Mailgun
Using Email to Send Push Notifications with Parse & Mailgun
 
I C T for JHS 3
I C T for JHS 3I C T for JHS 3
I C T for JHS 3
 
S N A I L Final Presentation
S N A I L    Final  PresentationS N A I L    Final  Presentation
S N A I L Final Presentation
 
8 Ways To Improve Email Performance During End-of-Year.pdf
8 Ways To Improve Email Performance During End-of-Year.pdf8 Ways To Improve Email Performance During End-of-Year.pdf
8 Ways To Improve Email Performance During End-of-Year.pdf
 
Pankaj Kh_Updated
Pankaj Kh_UpdatedPankaj Kh_Updated
Pankaj Kh_Updated
 
Top Essay Writing Websites
Top Essay Writing WebsitesTop Essay Writing Websites
Top Essay Writing Websites
 
Sales Email Hacks for Gmail and Salesforce
Sales Email Hacks for Gmail and SalesforceSales Email Hacks for Gmail and Salesforce
Sales Email Hacks for Gmail and Salesforce
 
Effective communication via email
Effective communication via emailEffective communication via email
Effective communication via email
 
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...
WIA 2019 - Using Embeddings to Understand the Variance and Evolution of Data ...
 
Onesocialweb Presentation at OTA10
Onesocialweb Presentation at OTA10Onesocialweb Presentation at OTA10
Onesocialweb Presentation at OTA10
 
Email and groupware
Email and groupwareEmail and groupware
Email and groupware
 
miniproject.ppt.pptx
miniproject.ppt.pptxminiproject.ppt.pptx
miniproject.ppt.pptx
 
Brains R Us Technology
Brains R Us TechnologyBrains R Us Technology
Brains R Us Technology
 
Brains R Us Technology
Brains  R  Us  TechnologyBrains  R  Us  Technology
Brains R Us Technology
 
Report on web development
Report on web developmentReport on web development
Report on web development
 
2. DD-sample.docx
2. DD-sample.docx2. DD-sample.docx
2. DD-sample.docx
 
Nova Spivack - Semantic Web Talk
Nova Spivack - Semantic Web TalkNova Spivack - Semantic Web Talk
Nova Spivack - Semantic Web Talk
 

More from Wise Engineering

Releasing Elixir/Phoenix Applications
Releasing Elixir/Phoenix ApplicationsReleasing Elixir/Phoenix Applications
Releasing Elixir/Phoenix ApplicationsWise Engineering
 
Transition to Infrastructure as Code
Transition to Infrastructure as CodeTransition to Infrastructure as Code
Transition to Infrastructure as CodeWise Engineering
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolutionWise Engineering
 
Launch safely with Feature Flags
Launch safely with Feature FlagsLaunch safely with Feature Flags
Launch safely with Feature FlagsWise Engineering
 
Search query assistance. Autosuggestion
Search query assistance. AutosuggestionSearch query assistance. Autosuggestion
Search query assistance. AutosuggestionWise Engineering
 
Build and release iOS apps using Fastlane tools
Build and release iOS apps using Fastlane toolsBuild and release iOS apps using Fastlane tools
Build and release iOS apps using Fastlane toolsWise Engineering
 

More from Wise Engineering (6)

Releasing Elixir/Phoenix Applications
Releasing Elixir/Phoenix ApplicationsReleasing Elixir/Phoenix Applications
Releasing Elixir/Phoenix Applications
 
Transition to Infrastructure as Code
Transition to Infrastructure as CodeTransition to Infrastructure as Code
Transition to Infrastructure as Code
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolution
 
Launch safely with Feature Flags
Launch safely with Feature FlagsLaunch safely with Feature Flags
Launch safely with Feature Flags
 
Search query assistance. Autosuggestion
Search query assistance. AutosuggestionSearch query assistance. Autosuggestion
Search query assistance. Autosuggestion
 
Build and release iOS apps using Fastlane tools
Build and release iOS apps using Fastlane toolsBuild and release iOS apps using Fastlane tools
Build and release iOS apps using Fastlane tools
 

Recently uploaded

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Scheduled delivery of a large amount of emails

  • 1. Scheduled delivery of a large amount of emails By trial and error Author Roman Valihura
  • 2. C O N T E N T 1. The mails delivery evolution 2. What our team is doing at Wise 3. Design scheduling architecture problems How to fetch emails in time How to send emails in time How to split emails between workers 4. Solutions conclusion
  • 3. We are here Usagesimplicity Time M A I L S D E L I V E R Y E V O L U T I O N
  • 4. What our team is doing at Wise We are creating an ESP (Email Service Provider) that provides convenient Rest API for working with large newsletters and collect statistics about how users interact with your emails
  • 5. U S E C A S E D I A G R A M R E G U L A R F L O W I N 3 0 D A Y S 3-party APP I N   9 0 D A Y S According to Wikipedia, a presentation is the process of presenting a topic to an audience. It is typically a demonstration, introduction, lecture, or speech meant to inform, persuade, or build good will. ESP API Send E mail HTTP Request GrayBox processing Sendemail to user Event Storage
  • 6. WE NEED A scheduling BETTER CONTROL Users can send emails in advance and monitor sending process from their side LESS LOAD FOR API You need to have less servers and less throughput if you have more time NO PERSONAL CRON You don't need personal CRON for delivery postponed emails
  • 7. U S E C A S E D I A G R A M S C H E D U L I N G F L O W ( S T A G E 0 ) 3-party APP I N   9 0 D A Y S According to Wikipedia, a presentation is the process of presenting a topic to an audience. It is typically a demonstration, introduction, lecture, or speech meant to inform, persuade, or build good will. ESP API Send E mail HTTP Request Sendemail to user Event Storage Scheduling Storage
  • 8. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E M E E T T H E W O R K E R ( V 1 ) Bio Name Worker (v1) Age 4 month Sex Male Responsibility Make query to data storage with certain interval Send ready to send emails to target users 
  • 9. How to find and fetch emails in time?
  • 10. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E M E E T T H E C L I C K H O U S E Bio Name ClickHouse Age 2 years 4 month Sex Undefined Features True column-oriented storage Local and distributed joins We use ClickHouse for events storage Metrics (EC2 c5.large) Read speed is 1.2 GB/s Write speed is 50 to 200 MB/s  Finding 335K scheduled emails on a dataset with size 5M take 0.061 second With network latency for transfer, we able to fetch 3.5M emails per second Summary
  • 11. U S E C A S E D I A G R A M S C H E D U L I N G F L O W ( S T A G E 1 ) 3-party APP I N   9 0 D A Y S According to Wikipedia, a presentation is the process of presenting a topic to an audience. It is typically a demonstration, introduction, lecture, or speech meant to inform, persuade, or build good will. ESP API Send E mail HTTP Request Sendemail to user Event Storage Clickhouse
  • 12. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E N O B O D Y I S P E R F E C T Bio Name Worker (v1) Age 4 month Sex Male Responsibility Make query to data storage with certain interval Send ready to send emails to target users  Disadvantages Works slow
  • 13. How to send emails in time when we have limited throughput?
  • 14. U S E C A S E D I A G R A M S C H E D U L I N G F L O W ( S T A G E 2 ) 3-party APP I N   9 0 D A Y S According to Wikipedia, a presentation is the process of presenting a topic to an audience. It is typically a demonstration, introduction, lecture, or speech meant to inform, persuade, or build good will. ESP API Send E mail HTTP Request Sendemail to user Event Storage Scheduling Storage
  • 15. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E N O B O D Y I S P E R F E C T Bio Name Worker (v1) Age 4 month Sex Regular Responsibility Make query to data storage with certain interval Send ready to send emails to target users  Disadvantages Works slow Not team member
  • 16. How to split emails between workers without duplicates?
  • 17. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E M E E T T H E R A N G E R Bio Name Ranger Age 4 month Sex Male Responsibility The Ranger is responsible for making a range for workers. Each range has unique properties that allow worker decide which records need to fetch from a database. Ready to send ranges creates internally. Throughput Working in pair with a ClickHouse as data storage, this system is able to create about 700 ranges per second with size 5000 emails.
  • 18. U S E C A S E D I A G R A M T H E R A N G E R F L O W Scheduling Storage (ClickHouse) Ranger [2018-10-08T07:47:56.144Z, 3], [2018-10-08T07:47:56.144Z, 4] ... dateFrom: Date('iso-format') dateTo: Date('iso-format') Workers Messaging Queue Send email to user dateFrom: Date('iso-format') dateTo: Date('iso-format')
  • 19. S O U R C E : W I S E C H A R A C T E R S D A T A B A S E M E E T T H E W O R K E R ( V 2 ) Bio Name Worker (v2) Age 3 month Sex Male Responsibility Pull Message Queue with ranges Fetch emails from ClickHouse by range payload Send emails to target users Advantages Works Team member
  • 20. U S E C A S E D I A G R A M T H E R A N G E R F L O W Scheduling Storage (ClickHouse) Ranger [2018-10-08T07:47:56.144Z, 3], [2018-10-08T07:47:56.144Z, 4] ... dateFrom: Date('iso-format') dateTo: Date('iso-format') Workers Messaging Queue Send email to user dateFrom: Date('iso-format') dateTo: Date('iso-format')
  • 21. U S E C A S E D I A G R A M S C H E D U L I N G F L O W ( S T A G E 3 ) I N 3 0 D A Y S 3-party APP ESP API Send E mail HTTP Request Send email to user Scheduling Storage (ClickHouse) Ranger Workers
  • 22. 01 02 03 HOW TO FETCH EMAILS IN TIME? We selected proper storage for that case. With Сlickhouse, we can fetch 335K records per second and filtering by ready date take 0.1 seconds for 5M database set (including network latency) HOW SEND EMAILS IN TIME? Obviously, we need a scaling for that case. Using multiple workers we can reach such throughput that we need. HOW TO SPLIT EMAILS FOR WORKERS? We created one more additional component that doing ranges for our workers and put them into a queue. Then each worker fetches different range from a queue.