XArchitecture 20140521
XArchitecture 20140521
AWS
Traffic IN
Traffic OUT
Internet Gateway
IP2
54.238.159.40
mailer.livecot.com
manager DEV
HAProxy NAT
repo + redis sessions all NAT server for outbound traffic from
Load balancer
private subnet.
IP4
54.238.142.142
API API worker worker worker worker
website website dev.livecot.com / dev.api.livecot.com
auto scale depending on emails volume DEV server (does all)
databases
NOT YET
YES
livecot_server.php
exists ?
NO UPDATE SETTINGS
Instance is running
The server checks if there is already a livecot_server.php file.
If yes, the server performs the CRON job unless a SHUTDOWN action
has been required.
wait next CRON job ...
If no, the server just wait until its running mode has been defined
In that case, this requires a manual action from an administrator :
artisan livecot:control start --mode=worker
CRON job
YES
livecot_server.php
exists ?
NO
YES
Notes:
IP
1- Another HAProxy can be placed in front
Management Layer
public access Background of many mailer instances if necessary
MANAGER Tasks
HAPROXY
NAT + REPOSITORY
LOAD BALANCER 2- Many Getter instances may be
+ REDIS
necessary in case of high volume of
1- Check newsletters newsletter emails to send in a short period
Allows IN traffic Allows OUT traffic
2- Manage instances of time.
3- Store sessions
3- Logs saved in S3 must include
information about the instance, like the
Application Layer instance_id
API + WEBSITE API + WEBSITE MAILER #1 GETTER 4- Can we combine the NAT and HAProxy
#1 #2 POSTFIX + REDIS #1 in one instance?
1- Keep logs
Hivelocity Inc.
Notes:
1- Based on DEV server alone, one Getter should be able to load 10,000 recipients in 2.5 min. It's 240,000 in one hour. 25 servers could get 6 million emails in one
hour. Taking into consideration a probably slower response time from clients,4 million emails could still be acceptable (see the sending capacity below).
2- Based on DEV server alone, one Mailer should be able to send at least 10,000 emails in 30 minutes. That's 20,000 emails per hour. 130 servers should be able to
send 2,600,000 emails per hour. Even more with better server specs (DEV server was only a c1.small)
Hivelocity Inc.
Notes:
IP
Management Layer
public access
MANAGER
DON'T RELEASE THE
HAPROXY
LOAD BALANCER
NAT + REPOSITORY
+ REDIS
FOLLOWING IP
ADDRESSES !
54.238.144.233 54.238.159.40 54.238.139.73
172.31.60.40
! 172.31.60.10
! 172.31.61.60 AWS registered them in whitelists.
54.238.144.233
Application Layer livecot.com
api.livecot.com
API + WEBSITE API + WEBSITE MAILER #1 GETTER
#1 #2 POSTFIX + REDIS #1 54.238.159.40
mailer.livecot.com
172.31.61.160 172.31.61.161 172.31.61.100
Data Layer
MySQL MySQL
AWS S3
MASTER (WRITE) SLAVE (READ)
172.31.61.20 172.31.61.30
Hivelocity Inc.
Data Layer
MySQL MySQL
AWS S3
MASTER (WRITE) SLAVE (READ)
1- Keep logs
Hivelocity Inc.
Data Layer
MySQL MySQL
AWS S3
MASTER (WRITE) SLAVE (READ)
1- Keep logs
Hivelocity Inc.
Instance Flow
Check newsletters
a1 CRON job every minute
Management Layer
prepare requests: offsets, limits
public access
MANAGER
HAPROXY Put get request in queue
NAT + REPOSITORY
LOAD BALANCER a2 getter can be dedicated instance or
+ REDIS
manager instance.
For now we consider a dedicated
Allows IN traffic Allows OUT traffic a1 1- Check newsletters a2 instance.
2- Manage instances
3- Store sessions
Application Layer
Data Layer
MySQL MySQL
AWS S3
MASTER (WRITE) SLAVE (READ)
1- Keep logs
Hivelocity Inc.
Instance Flow
POP get request
b1 check client URL, prepare request with
Management Layer
credentials, offset and limit
public access
MANAGER
HAPROXY Request recipients
NAT + REPOSITORY
LOAD BALANCER b2 limit 1000
+ REDIS
Data Layer
MySQL MySQL
AWS S3
MASTER (WRITE) SLAVE (READ)
1- Keep logs
Hivelocity Inc.
CRON Jobs
- CRON jobs are performed every minute
- scripts are loaded by task/taskboot.php
- scripts are located at Livecot/Task/...
- scripts are executed like this:
php path/to/task/taskboot.php [env] [type] [action]
1- Keep logs
7 7
Notes:
(1) : The process should be unique. Every minute
a CRON job is launched but the process
performs a check based on the script name and
its own process id (pid). If another pid is found for
the same script name, the job is cancelled.
This ensure that only one process is doing the
job, but if that process dies, it will be replaced by
another one in less than one minute.
NO
to improve the API speed. NO
YES YES
NO NO
Template Template
Return Error Return Error
exists ? exists ?
YES YES
Get template
Put the email in
the Redis Queue
NO
The email will be sent later.
Use URLs
redirection ?
Most of the time it will be sent
YES
instantly, unless there is a high
amount of traffic. In that case, the
sending server will launch or wake
Check and replace URLs
up other sending servers to help.
Send Email
Hivelocity Admin