Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Multi-Region Serverless Architecture and Breaking them using Chaos Engineering

Building Multi-Region Serverless Architecture and Breaking them using Chaos Engineering

Customers are often looking at running their services at global scale, deploying applications to multiple regions. While it has traditionally been hard to do this, often requiring months of engineering work, serverless has changed the game!
This hands-on talk will help you understand how to build different versions of a multi-region, active-active serverless backend.
Come learn the pros-and-cons of DNS routing versus IP Anycast, and see how you can leverage serverless services like Route 53, Global Accelerator, API Gateway, the Application Load Balancer, AWS Lambda and DynamoDB Global tables to build global scale, serverless applications.
While having a multi-region architecture increases the availability of your application, it also brings new sets of challenges.
One of these challenge is ensuring that the failover procedures work when needed since the last thing you want during a disaster is fixing the failover procedures. This session will also look into using chaos engineering techniques to make sure that when the real disaster happens, the failover is successful.

Adrian Hornsby

February 03, 2020
Tweet

More Decks by Adrian Hornsby

Other Decks in Technology

Transcript

  1. © 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

    View full-size slide

  2. Why build a global architecture?

    View full-size slide

  3. Once upon a time …
    Origin

    View full-size slide

  4. And now . . .
    Origin
    ~300ms

    View full-size slide

  5. Origin
    Improve latency for end users
    Origin

    View full-size slide

  6. 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

    View full-size slide

  7. Amazon global network

    View full-size slide

  8. Origin
    Cross-region VPC peering
    Origin

    View full-size slide

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

    View full-size slide

  10. 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

    View full-size slide

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

    View full-size slide

  12. Serverless cost model is a huge advantage here!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. 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

    View full-size slide

  16. Multi-region with
    Route 53 Amazon Route 53

    View full-size slide

  17. Latency-based routing
    Application Application
    Amazon Route 53
    Region Region

    View full-size slide

  18. Geo-based routing
    Application Application
    Amazon Route 53
    Region Region

    View full-size slide

  19. Weighted round robin routing
    Application Application
    Amazon Route 53
    Region Region

    View full-size slide

  20. DNS failover
    Application Application
    Region Region
    Amazon Route 53

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. 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

    View full-size slide

  24. Route53: Traffic policy

    View full-size slide

  25. Health checks with Route 53

    View full-size slide

  26. 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à!

    View full-size slide

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

    View full-size slide

  28. 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

    View full-size slide

  29. AWS Global Accelerator

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  32. 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

    View full-size slide

  33. 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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  38. Amazon CloudFront AWS Lambda
    Lambda@Edge
    Lambda@Edge

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  41. 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);
    }

    View full-size slide

  42. #awssummit
    Joris Andrade
    Software Engineer
    FrontApp
    @Zambka

    View full-size slide

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

    View full-size slide

  44. #awssummit
    Multi-region Setup

    View full-size slide

  45. #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.

    View full-size slide

  46. #awssummit
    Reduce latency for
    global teams

    View full-size slide

  47. Lambda @ Edge

    View full-size slide

  48. #awssummit
    Live Demo

    View full-size slide

  49. #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

    View full-size slide

  50. https://medium.com/@adhorn

    View full-size slide

  51. Thank you!
    © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Adrian Hornsby
    [email protected]

    View full-size slide