(SDD412) Amazon Simple Email Service Deep Dive and Best Practices | AWS re:Invent 2014

Post on 30-Jun-2015

344 views 5 download

description

Almost all applications and services have a need to communicate over email. Amazon Simple Email Service (SES) enables email functionality that will scale with your business. So what should an email-sending application that integrates with SES look like? In this session we cover common patterns, architectures, and best practices that you can use to build a robust email solution that takes advantage of the SES platform.

Transcript of (SDD412) Amazon Simple Email Service Deep Dive and Best Practices | AWS re:Invent 2014

SMTP

HTTPS

ISPs

Amazon SES

• Amazon SES integrates with Amazon Route 53

DKIM with Amazon SES (2/2)

• Automatic key rotation

Sender Amazon SESSigned Email

ISP

Add DKIM Signature

Signed Email 2

DNS

Fetch Public DKIM Key

• Use HTTP instead of SMTP

• Use persistent connections

• Send in parallel– Use multiple processes/threads

– Use multiple hosts

SMTP HTTPS

Introduction

Example

– Bounce

– Complaint

– Delivery

Amazon SNSEmail

permanent, transient undetermined

– Invalid email address

– Mailbox full

– Message too large

Recommended actions:

– Permanent: Stop sending to address

– Transient: Depends on type

– Undetermined: Manually review

spam

Recommended action: Stop sending to address

successful delivery

Common actions: Auditing and tracking

ISP SenderAmazon SES Amazon SNS

SendEmail

Complaint Complaint Notification

Delivery Notification

SNS Topic

{

"notificationType":"Bounce",

"bounce":{

"bounceType":"Transient",

"bounceSubType":"MailboxFull",

"bouncedRecipients":[{

"emailAddress":"username@example.com",

"diagnosticCode":"550 5.2.2 Rcpt Mailbox Full"

}],

"timestamp":"2015-06-19T01:07:52.000Z"

},

"mail":{

"source":"sender@example.com",

"messageId":"00000138111222aa-33322211-cccc-dddd"

}

}

Amazon SQSAmazon SNS AWS Elastic Beanstalk

1. Configure SNS topic to receive notifications

2. Create SQS queue and subscribe to SNS topic

3. Create Elastic Beanstalk worker tier application

4. Deploy Python notification processor

ISP SenderAmazon SESAmazon

SNS

SendEmail

Complaint Notification

SNS topic SQS queue

Amazon

SQS

1. Configure SNS topic to receive notifications

2. Create SQS queue and subscribe to SNS topic

3. Create Elastic Beanstalk worker tier application

4. Deploy Python notification processor

Amazon

SQS

AWS

Elastic Beanstalk

Amazon

RDS

1. Configure SNS topic to receive notifications

2. Create SQS queue and subscribe to SNS topic

3. Create Elastic Beanstalk worker tier application

4. Deploy Python notification processor

Get message from queue and

post to app

Parse notification & determine

type

Update email list or manually

review

Return success response

Delete message from queue

application = flask.Flask(__name__)

@application.route('/process', methods=['POST'])

def process():

message = json.loads(request.json['Message'])

if message['notificationType'] == 'Bounce’:

if message['bounce']['bounceType'] == 'Permanent':

remove_recipients_from_list(message)

elif message['bounce']['bounceType'] == 'Transient':

if message['bounce']['bounceSubType'] == 'MailboxFull':

temporarily_suspend_sending(message)

else:

manually_review_notification(message)

else:

manually_review_notification(message)

elif message['notificationType'] == 'Complaint':

remove_recipients_from_list(message)

return Response("", status=200)

Handle new

notification

types

Return success

response

Use Flask for

HTTP server

1. Configure SNS topic to receive notifications

2. Create SQS queue and subscribe to SNS topic

3. Create Elastic Beanstalk worker tier application

4. Deploy Python notification processor

mailbox simulator

bounce@simulator.amazonses.com

complaint@simulator.amazonses.com

Introduction

Example

merchandizer message

customers

customer message

CustomerMerchandizers Message

merchandizer planner

message customer

customer

Merchandizers CustomerMessage Planner

merchandizers customer

message

CampaignID List of RecipientIDs

1 [1,2]

2 [2]

3 [2,3]

cn [r1,r2,r3,…]

Map

Map Reduce

Best

campaign

commit

Prioritization

Logic

Within 6 months Within 4-10 months

Holdout

Population that

will receive message5¢/mail

6¢/mail

Within 6 months

For each recipient R

For each email campaign M targeting R

For each experiment E containing campaign M

End For

End For

End For

Within 6 months Within 4-10 months

Within 6 months Within 4-10 months

Within 6 months Within 4-10 months

Within 6 months Within 4-10 months

Incremental

value A

Incremental

value B

We should use group B for targeting

Within 6 months Within 4-10 months

Incremental

value A

Incremental

value B

We should use both groups for targeting

Within 6 months Within 4-10 months

Please give us your feedback on this session.

Complete session evaluations and earn re:Invent swag.

http://bit.ly/awsevals