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

How to build a global serverless service [AWS Dev Day @ Kyiv]

How to build a global serverless service [AWS Dev Day @ Kyiv]

Alex Casalboni

June 11, 2019
Tweet

More Decks by Alex Casalboni

Other Decks in Programming

Transcript

  1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    0 6 . 1 1 . 1 9
    How to build a global
    serverless service
    Alex Casalboni
    Technical Evangelist
    Amazon Web Services
    @alex_casalboni

    View Slide

  2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    About me
    • Software Engineer & Web Developer
    • Worked in a startup for 4.5 years
    • ServerlessDays Organizer
    • AWS Customer since 2013

    View Slide

  3. View Slide

  4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    How (and why) do we build
    global serverless services?

    View Slide

  5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Some fundamentals first!

    View Slide

  6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Availability in parallel
    A = 1 – (1 – Ax)2
    Part X
    Part X

    View Slide

  7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Availability in parallel
    Component Availability Downtime
    X 99% (2-nines) 3 days 15 hours
    Two X in parallel 99.99% (4-nines) 52 minutes
    Three X in parallel 99.9999% (6-nines) 31 seconds

    View Slide

  8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Component redundancy increases
    availability significantly!

    View Slide

  9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    21 Geographic Regions
    66 Availability Zones (AZs)
    Upcoming: 4 regions and 12 AZs

    View Slide

  10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    AWS Region and availability zones
    Region
    Availability zone a Availability zone b Availability zone c
    data center
    data center
    data center
    data center
    data center
    data center
    data center
    data center
    data center

    View Slide

  11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Multi-AZ
    Region
    Availability zone a Availability zone b Availability zone c
    Application Application Application
    ELB

    View Slide

  12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Multi-region
    Region
    Availability
    zone a
    Availability
    zone b
    Availability
    zone c
    Application
    Region
    Availability
    zone a
    Availability
    zone b
    Availability
    zone c
    Application Application Application Application
    Application
    Route 53

    View Slide

  13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Serverless components
    Region
    Availability zone a Availability zone b Availability zone c
    Serverless Services

    View Slide

  14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Why serverless components??
    No provisioning,
    no management
    Pay for value
    Fault Tolerant and
    Automatic scaling
    Highly available
    and secure

    View Slide

  15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Why build a multi-region
    active-active architecture?

    View Slide

  16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Improve latency for end-users
    ~300ms
    ~140ms

    View Slide

  17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    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 Slide

  18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Prerequisites to building a
    multi-region architecture

    View Slide

  19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    CAP Theorem
    Consistency Availability Partition Tolerance
    Data is consistent.
    All nodes see the same state.
    Every request is non-failing. Service still responds as expected
    if some nodes crash.
    Distributed System
    In the presence of a network partition, you must
    choose between consistency and availability!

    View Slide

  20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Embrace eventual consistency
    … if no new updates are made to a
    given data item, eventually all
    accesses to that item will return the
    last updated value.
    Availability
    An eventually consistent system can
    return any value before it converges!!
    https://en.wikipedia.org/wiki/Eventual_consistency
    Distributed System
    Every request is non-failing.

    View Slide

  21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Secure and reliable global network
    youtube.com/watch?v=AyOAjFNPAbA

    View Slide

  22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    How can you achieve data replication?

    View Slide

  23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    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 Slide

  24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Replicates your data with no impact on database performance
    Typical cross-region replication latencies below 1 second
    An Aurora cluster can recover in less than 1 minute even in
    the event of a complete regional outage
    Recovery Point Objective (RPO) of 1 second
    Recovery Time Objective (RTO) of less than 1 minute
    Amazon Aurora Global Database
    Designed for globally distributed applications
    Globally dispersed users
    Replica (N. America)
    Replica (Europe)
    Replica (Asia)
    Global App
    Global Table

    View Slide

  25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Amazon S3 cross-region replication
    S3 Bucket S3 Bucket

    View Slide

  26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    What about routing?

    View Slide

  27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Global routing with
    Route 53 Route 53

    View Slide

  28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Latency based routing
    Region
    Region
    Application Application

    View Slide

  29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Geo-based routing
    Region us-east-1
    Region us-west-2
    Application Application

    View Slide

  30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Weighted round robin routing
    Region us-east-1
    Region us-west-2
    Application Application

    View Slide

  31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    DNS failover
    Region us-east-1
    Region us-west-2
    Application Application

    View Slide

  32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    AWS Global Accelerator

    View Slide

  33. AWS Global Accelerator: Before and After

    View Slide

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

    View Slide

  35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    Global Table
    AWS Lambda
    AWS Lambda
    Amazon DynamoDB
    Amazon DynamoDB
    Amazon API Gateway
    Amazon API Gateway
    Amazon Route 53

    View Slide

  36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    Global Table
    Amazon DynamoDB
    Amazon DynamoDB

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    Global Table
    AWS Lambda
    AWS Lambda
    Amazon DynamoDB
    Amazon DynamoDB

    View Slide

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

    View Slide

  44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    Global Table
    AWS Lambda
    AWS Lambda
    Amazon DynamoDB
    Amazon DynamoDB
    Amazon API Gateway
    Amazon API Gateway

    View Slide

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

    View Slide

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

    View Slide

  47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    Global Table
    AWS Lambda
    AWS Lambda
    Amazon DynamoDB
    Amazon DynamoDB
    Amazon API Gateway
    Amazon API Gateway
    Amazon Route 53

    View Slide

  48. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Route53: Latency-based routing

    View Slide

  49. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Let’s see it in action!
    https://map.global.faas.website

    View Slide

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

    View Slide

  51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    A quick look at SLA’s
    AWS Lambda: 99.95% (4h of downtime)
    Amazon API Gateway: 99.95% (4h of downtime)
    Amazon DynamoDB: 99.999% (5min of downtime)
    Route 53: 100% (no downtime)

    View Slide

  52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    AWS Lambda
    AWS Lambda
    Amazon DynamoDB
    Amazon DynamoDB
    Amazon API Gateway
    Amazon API Gateway
    Amazon Route 53

    View Slide

  53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    99.95% 99.95% 99.999%
    99.95% 99.95% 99.999%
    100%

    View Slide

  54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    99.899%
    100%
    99.95% 99.95% 99.999%

    View Slide

  55. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Region eu-west-1
    Region eu-central-1
    99.899%
    100%
    99.9898%
    (2 regions)
    99.95% 99.95% 99.999%

    View Slide

  56. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    With 1 region: 99.899% (9h of downtime)
    With 2 regions: 99.9898% (1h of downtime)
    With 3 regions: 99.999% (5min of downtime)
    With 4 regions: 99.9999% (30s of downtime)
    With 5 regions: 100% (no downtime)

    View Slide

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

    View Slide

  58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Want to read more?
    bit.ly/adhorn-serverless-multi-region

    View Slide

  59. Thank you!
    © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Alex Casalboni
    @alex_casalboni

    View Slide