Slide 1

Slide 1 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Building multi-region, active-active serverless applications Adrian Hornsby Principal Evangelist Amazon Web Services @adhorn

Slide 2

Slide 2 text

Why build a global architecture?

Slide 3

Slide 3 text

Once upon a time … Origin

Slide 4

Slide 4 text

And now . . . Origin ~300ms

Slide 5

Slide 5 text

Origin Improve latency for end users Origin

Slide 6

Slide 6 text

Improve availability and disaster recovery Applications in US West Applications in US East Users from San Francisco Users from New York Service 1 Service 2 Service 3 Service 4 Service 1 Service 2 Service 3 Service 4

Slide 7

Slide 7 text

Amazon global network

Slide 8

Slide 8 text

Origin Cross-region VPC peering Origin

Slide 9

Slide 9 text

Amazon S3 cross-region replication Bucket with objects Bucket with objects

Slide 10

Slide 10 text

Build high performance, globally distributed applications Low latency reads & writes to locally available tables Disaster proof with multi-region redundancy Easy to set up and no application rewrites required Globally dispersed users Replica (N. America) Replica (Europe) Replica (Asia) Global App Global Table Amazon DynamoDB Global Tables Fully managed, multi-master, multi-region database

Slide 11

Slide 11 text

Active-Active | Active-Passive | What to do?

Slide 12

Slide 12 text

Serverless cost model is a huge advantage here!

Slide 13

Slide 13 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 14

Slide 14 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Route 53 > API Gateway > Lambda > DynamoDB

Slide 15

Slide 15 text

Global Table https://global.adhorn.me AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB Amazon API Gateway Amazon API Gateway Amazon Route 53 Region Region us-east-1 Region Region us-west-2

Slide 16

Slide 16 text

Multi-region with Route 53 Amazon Route 53

Slide 17

Slide 17 text

Latency-based routing Application Application Amazon Route 53 Region Region

Slide 18

Slide 18 text

Geo-based routing Application Application Amazon Route 53 Region Region

Slide 19

Slide 19 text

Weighted round robin routing Application Application Amazon Route 53 Region Region

Slide 20

Slide 20 text

DNS failover Application Application Region Region Amazon Route 53

Slide 21

Slide 21 text

Global Table Amazon DynamoDB Amazon DynamoDB Region Region Region us-east-1 Region us-west-2

Slide 22

Slide 22 text

Global Table AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB Region Region Region us-east-1 Region us-west-2

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

https://globalddb.adhorn.me Regional API Endpoint Custom Domain Name Regional API Endpoint Custom Domain Name API Gateway Amazon API Gateway Amazon API Gateway AWS Lambda AWS Lambda Amazon Route 53 Region Region

Slide 25

Slide 25 text

Route53: Traffic policy

Slide 26

Slide 26 text

Health checks with Route 53

Slide 27

Slide 27 text

Global Table https://global.adhorn.me AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB Amazon API Gateway Amazon API Gateway Amazon Route 53 Region Region us-east-1 Region Region us-west-2 Voilà!

Slide 28

Slide 28 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Global Accelerator > Load Balancer > Lambda > DynamoDB

Slide 29

Slide 29 text

Global Table AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB AWS Global Accelerator Application Load Balancer Application Load Balancer Region Region eu-central-1 Region Region us-west-2

Slide 30

Slide 30 text

AWS Global Accelerator

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Global Table Amazon DynamoDB Amazon DynamoDB Region Region eu-central-1 Region Region us-west-2

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Global Table AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB Region Region eu-central-1 Region Region us-west-2

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Global Table AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB Application Load Balancer Application Load Balancer Region Region eu-central-1 Region Region us-west-2

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Global Table AWS Lambda AWS Lambda Amazon DynamoDB Amazon DynamoDB AWS Global Accelerator Application Load Balancer Application Load Balancer Voilà! Region Region eu-central-1 Region Region us-west-2

Slide 45

Slide 45 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. N EW - BETA

Slide 48

Slide 48 text

N EW - BETA

Slide 49

Slide 49 text

N EW - BETA

Slide 50

Slide 50 text

N EW - BETA

Slide 51

Slide 51 text

N EW - BETA

Slide 52

Slide 52 text

N EW - BETA

Slide 53

Slide 53 text

N EW - BETA

Slide 54

Slide 54 text

N EW - BETA

Slide 55

Slide 55 text

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html N EW - BETA

Slide 56

Slide 56 text

© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 57

Slide 57 text

Amazon CloudFront AWS Lambda Lambda@Edge Lambda@Edge

Slide 58

Slide 58 text

Lambda@Edge Events CloudFront cache Viewer Response Origin Response Origin Origin Request Viewer Viewer Request

Slide 59

Slide 59 text

Write Once, Run Lambda Functions Globally N Virginia AWS Location AWS Location AWS Location AWS Location AWS Location AWS Location

Slide 60

Slide 60 text

Lambda@Edge Programming Model exports.handler = (event, context, callback) => { /* viewer-request and origin-request events * have the request as input */ const request = event.Records[0].cf.request; /* viewer-response and origin-response events * have the response as input */ const response = event.Records[0].cf.response; /* Do the processing – say add a header */ /* When I am done I let CloudFront what to do next */ callback(null, request); }

Slide 61

Slide 61 text

#awssummit Joris Andrade Software Engineer FrontApp @Zambka

Slide 62

Slide 62 text

#awssummit Multi-region setup • Data from a customer in only 1 region • US-West-1 ! / EU-West-1 " • Dynamic routing with DynamoDB • VPC Peering

Slide 63

Slide 63 text

#awssummit Multi-region Setup

Slide 64

Slide 64 text

#awssummit High Latency for global teams Customers with global teams experience very high latencies when their API traffic is routed to their “home” region through a different intermediate region.

Slide 65

Slide 65 text

#awssummit Reduce latency for global teams

Slide 66

Slide 66 text

Lambda @ Edge

Slide 67

Slide 67 text

#awssummit Live Demo

Slide 68

Slide 68 text

#awssummit Takeaways Great impact for our global customers : up to 50% latency reduction 0 0.5 1 1.5 2 2.5 AVG P50 P95 P99

Slide 69

Slide 69 text

https://medium.com/@adhorn

Slide 70

Slide 70 text

Thank you! © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Adrian Hornsby adhorn@amazon.com