SlideShare a Scribd company logo
1 of 39
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Magnus Bjorkman, AWS Solution Architect
Stefano Buliani, AWS Specialist Solution Architect
December 4, 2017
Tech Talk:
Serverless Applications at Global
Scale with Multi-Regional
Deployments
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHAT TO EXPECT FROM THE SESSION
• FOOD FOR THOUGHT – a real world serverless application
• Why go multi-region?
• Decision tree – do even need to go multi-region?
• One service at a time – routing and data replication concepts:
• Browsing catalog
• Updating catalog
• Receiving orders
• Summary
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Example Application
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“FOOD-FOR-THOUGHT”
• Order food from any restaurant near you and get it delivered at your home
• Store and browse restaurant menu items
• Accept orders and process payments
• Company doing business through-out North America and Europe
• Customers should see low latency and high-performance at either continent.
• Very high peak to average ratio of traffic around meal times
• A highly fault-tolerant system is critical as reputational and revenue loss would
be significant for an outage during those hours
Photo by Brigitte Tohm on Unsplash
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BENEFITS OF LAMBDA AND SERVERLESS
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHY ARE “FOOD-FOR-THOUGHT” GOING MULTI-REGION?
Data Sovereignty
Increased Fault
Tolerance
Improved Latency and
Performance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What “food-for-thought” should
consider when going multi-region?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“FOOD-FOR-THOUGHT” – 3 KEY SERVICES
Browse Catalog
• View
Restaurants
• View Menus
Submit Order
• Order Processing
• Payment
Processing
• Order
Confirmation
Update Catalog
• Add, Update and
Remove
Restaurants
• Add, Update and
Remove Menus
Customer
Administrator
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DOES IT NEED TO BE MULTI-REGION?
Core to
business
• Is this service truly core to
our business?
• How does this service
access persistent storage?
Multi-Region
DNS routing
Single Region
Scheduled
Replication
Master/
Master
Near Real-Time
Eventual Consistency
from Master Copy
Master/
Slave
Read-Only Read-Write
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
HOW MUCH WILL THIS COST?
• Lambda and API Gateway only charge when code executes – traffic
is the same, price is the same, not matter how many regions
• Database and file storage will incur additional charges, for fully
redundant services your costs increase
• Data transfer out to internet costs can vary depending on the region
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MONITORING AND LOGGING
• Monitoring
• Fine-grained monitoring within the region
• Enough monitoring from outside region to detect issue in
region, especially with monitoring system
• Logging
• Consider replicating logs if they are critical to operations
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DATA SOVEREIGNTY
• For data under purview of Data Sovereignty laws:
• Implement requirements into application code and do not
solely rely on routing features like geographic routing in Route
53
• Consider using home regions for users and make sure that the
code/data is always executed/stored in that particular region for
that particular user.
• Use separate Cognito User Pools in each region
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Browsing and updating catalog
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BROWSING AND UPDATING CATALOG
• Availability:
• It is critical to be able to browse the catalog
so customers can create orders.
• It is less critical to be able to update the
catalog.
• Consistency:
• It is required to have at least eventual read
consistency.
• External Dependencies:
• None
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BROWSING THE CATALOG
Core to
business
• Is this service truly core to
our business?
• YES – we need the
catalog in order to
accept orders
• How does this service
access persistent storage?
• Data replicated to all
regions from master
copy
Multi-Region
DNS routing
Single Region
Scheduled
Replication
Master/
Master
Near Real-Time
Eventual Consistency
from Master Copy
Master/
Slave
Read-Only Read-Write
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
UPDATING THE CATALOG
Core to
business
• Is this service truly core to
our business?
• NO – even if the master
region is down we can
still accept orders.
• The architectural
complexity of
master/master
replication is not worth
the return.
Multi-Region
DNS routing
Single Region
Scheduled
Replication
Master/
Master
Near Real-Time
Eventual Consistency
from Master Copy
Master/
Slave
Read-Only Read-Write
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BROWSING CATALOG - ARCHITECTURE
us-west-2
us-east-1
Amazon
Route 53
mobile client
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BROWSING CATALOG – ARCHITECTURE HIGHLIGHTS
• Active-Active multi-regional API
• Deploy same stack to multiple regions
• Read-Only. Access DynamoDB tables in local region
• Optional: For public and content more static in nature, put CloudFront
in front of API.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
API GATEWAY: REGIONAL ENDPOINTS
• Endpoint configuration types
• Edge optimized
• Regional
• Endpoint configuration types are applicable for both Custom Domain
Names as well as APIs
• Regional Endpoints: Custom domains are unique per region
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MULTI-REGION API GATEWAY SETUP
• Endpoints in AWS
Regions
• Amazon Route 53
Routing (e.g. Latency,
Geolocation)
• Multi-Region Backends
• Active-Active
us-west-2
us-east-1
mobile client
Amazon
Route 53 API
Endpoint
API
Endpoint
Custom
Domain
Name
Endpoint
Custom
Domain
Name
Endpoint
Amazon
API Gateway
AWS
Lambda
Amazon
API Gateway
AWS
Lambda
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
FAIL-OVER ACROSS REGIONS WITH API GATEWAY
• Amazon Route 53
health checks
• Provide a path that
does a deep ping
us-west-2
us-east-1
mobile client
Amazon
Route 53 API
Endpoint
API
Endpoint
Custom
Domain
Name
Endpoint
Custom
Domain
Name
Endpoint
Amazon
API Gateway
AWS
Lambda
Amazon
API Gateway
AWS
Lambda
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
UPDATING CATALOG - ARCHITECTURE
us-west-2
us-east-1
mobile client
Amazon
Route 53
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
UPDATING CATALOG – ARCHITECTURE HIGHLIGHTS
• Single-Region API. Updates are lower criticality than reads. Graceful
degradation.
• Data availability is critical for “Browse Catalog” use case. Replicate to
other regions using DynamoDB streams.
• Simplify
• No data conflicts
• No split brain
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MASTER/SLAVE REPLICATION WITH LAMBDA
for record in event['Records']:
print(record['eventID'])
print(record['eventName'])
print("DynamoDB Record: ”
+ json.dumps(record['dynamodb'], indent=2))
if (record['eventName'] == 'INSERT') or
(record['eventName'] == 'MODIFY'):
client.put_item(TableName=resource_properties['TargetDDB'],
Item=record['dynamodb']['NewImage'])
elif record['eventName'] == 'REMOVE':
client.delete_item(TableName=resource_properties['TargetDDB'],
Key=record['dynamodb']['Keys'])
us-west-2
us-east-1
AWS
Lambda
Amazon
DynamoDB
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Submit order
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SUBMIT ORDER
• Availability:
• It is critical to be able to write new orders.
• It is critical to be able to read and update existing
orders.
• Consistency:
• It is required to have at least eventual read consistency
for status of existing orders.
• It is required to have strong consistency for read-before-
write.
• External Dependencies:
• Payment System
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DECISION TREE
Core to
business
• Is this service truly core to
our business?
• YES – it’s our primary
revenue source
• How does this service
access persistent storage?
• Each order has a
master region. Orders
are replicated but can
only be modified in their
master region.
Multi-Region
DNS routing
Single Region
Scheduled
Replication
Master/
Master
Near Real-Time
Eventual Consistency
from Master Copy
Master/
Slave
Read-Only Read-Write
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SUBMIT ORDER – ALMOST MASTER / MASTER
• True master/master replication is very hard:
• Multi-region ACID transactions are impractical
• Orders have a master region
• Writes always go to the master region
• Reads for processing can happen in any region
• Client logic to ensure updates always go to the master region
• Other regions should refuse to modify the order if they receive a
request
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHY HOME REGION IF MULTI-MASTER IS POSSIBLE
• Multi-master is very complex – chances of bugs are higher
• Eventual consistency in reads can create a frustrating customer
experience – I don’t know what the true state of my order is
• Erodes customer trust quickly
• Losing an entire region is highly unlikely, much less likely than order
state being inconsistent across the two regions
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
APPLICATION STATE – CLIENT SIDE
us-west-2
us-east-1
Amazon
Route 53
1.
Client uses the DNS-
balanced endpoint to
create an order
2.
Region creates the order
and sets itself as the
master
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
HOME REGION REPLICATION
• Each order/record has a home region. Only
write to home region.
• Read from home region unless not available.
• Mark initial record for replication to avoid
circular updates.
us-west-2
us-east-1
orderId homeRegion userId
1234 us-east-1 9012
5678 us-west-2 3456
Update
Lambda
Replication
Lambda
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
APPLICATION STATE – CLIENT SIDE
us-west-2
us-east-1
Amazon
Route 53
3.
Client addresses
home region
Directly to update
order
4.
Once written, any
region can process
the order
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SUBMIT ORDER - ARCHITECTURE
us-west-2
us-east-1
mobile client
Amazon
Route 53
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
Amazon
API Gateway
AWS
Lambda
Amazon
DynamoDB
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MASTER/MASTER REPLICATION: OTHER OPTIONS
• Pessimistic locking when writing to all stores.
• Strong consistency
• Lock contention and potential lower through-put
• Lower availability
• Quorum based algorithms
• Eventual consistency but with reduced risk of write conflicts
• At least 3 replicas
• Lower availability with certain network partitions
• Conflict-free replicated data type (CRDT)
• Works well for certain data structure but not others
• Need to define merge logic for each CRDT
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SUBMIT ORDER – ARCHITECTURE HIGHLIGHTS
• Active-Active Multi-Regional API
• Health Checks need to include External Dependencies
• Are your dependencies also multi-region?
• Deploy Same Stack to Multiple Regions
• Data Replication using DynamoDB Streams:
• Eventual Consistency. No 2-Phase Commits
• Primary key will include home region.
• Client is smart about regional availability
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Summary
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
TAKE AWAYS
• Multi-region architectures add significant complexity to your stack –
think carefully about your services and whether they need to be multi
region at all
• Master/master replication with eventual consistency may create a
worse customer experience than losing the entire order – full
regional outages are highly unlikely, keep it simple!
• Route53 can perform failover checks and most operation can be
automated – this does not exonerate operators and developers from
the job of monitoring their service. Create relevant metrics and set
alarm on them.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
NEXT STEPS
• Learn more from our multi-region serverless API blog post:
AWS Compute Blog: Building a Multi-region Serverless
Application with Amazon API Gateway and AWS Lambda
• API Gateway regional endpoints give you control over your DNS
records:
https://docs.aws.amazon.com/apigateway/latest/developerguide/create-regional-api.html
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You
Magnus Bjorkman, AWS Solution Architect
Stefano Buliani, AWS Specialist Solution Architect

More Related Content

What's hot

Oracle GoldenGate for Zero Downtime Migration
Oracle GoldenGate for Zero Downtime MigrationOracle GoldenGate for Zero Downtime Migration
Oracle GoldenGate for Zero Downtime MigrationFumiko Yamashita
 
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)Kai Wähner
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodeFrederic Descamps
 
Ndb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_memNdb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_memmikaelronstrom
 
Apache CouchDB
Apache CouchDBApache CouchDB
Apache CouchDBHugo Souza
 
Qlik Replicate - IBM DB2 for LUWを ソースおよびターゲットエンドポイントとして使用する
Qlik Replicate - IBM DB2 for LUWをソースおよびターゲットエンドポイントとして使用するQlik Replicate - IBM DB2 for LUWをソースおよびターゲットエンドポイントとして使用する
Qlik Replicate - IBM DB2 for LUWを ソースおよびターゲットエンドポイントとして使用するQlikPresalesJapan
 

What's hot (7)

Oracle GoldenGate for Zero Downtime Migration
Oracle GoldenGate for Zero Downtime MigrationOracle GoldenGate for Zero Downtime Migration
Oracle GoldenGate for Zero Downtime Migration
 
MySQL8.0 in COSCUP2017
MySQL8.0 in COSCUP2017MySQL8.0 in COSCUP2017
MySQL8.0 in COSCUP2017
 
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
Apache Kafka vs. Integration Middleware (MQ, ETL, ESB)
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
Ndb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_memNdb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_mem
 
Apache CouchDB
Apache CouchDBApache CouchDB
Apache CouchDB
 
Qlik Replicate - IBM DB2 for LUWを ソースおよびターゲットエンドポイントとして使用する
Qlik Replicate - IBM DB2 for LUWをソースおよびターゲットエンドポイントとして使用するQlik Replicate - IBM DB2 for LUWをソースおよびターゲットエンドポイントとして使用する
Qlik Replicate - IBM DB2 for LUWを ソースおよびターゲットエンドポイントとして使用する
 

Similar to Serverless Applications at Global Scale with Multi-Regional Deployments - AWS Online Tech Talks

SRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsSRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsAmazon Web Services
 
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...Amazon Web Services
 
Migrating to Amazon RDS with Database Migration Service:
Migrating to Amazon RDS with Database Migration Service:Migrating to Amazon RDS with Database Migration Service:
Migrating to Amazon RDS with Database Migration Service:Amazon Web Services
 
Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech TalksBuilding Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech TalksAmazon Web Services
 
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaScale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaAmazon Web Services
 
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...Amazon Web Services
 
ATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsAmazon Web Services
 
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveGPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveAmazon Web Services
 
Introduction to AWS for Mobile Developers
Introduction to AWS for Mobile DevelopersIntroduction to AWS for Mobile Developers
Introduction to AWS for Mobile DevelopersAmazon Web Services
 
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)Amazon Web Services
 
What’s New in Amazon RDS for Open-Source and Commercial Databases:
What’s New in Amazon RDS for Open-Source and Commercial Databases: What’s New in Amazon RDS for Open-Source and Commercial Databases:
What’s New in Amazon RDS for Open-Source and Commercial Databases: Amazon Web Services
 
Intro To AWS for Mobile Developers: Collision 2018
Intro To AWS for Mobile Developers: Collision 2018Intro To AWS for Mobile Developers: Collision 2018
Intro To AWS for Mobile Developers: Collision 2018Amazon Web Services
 
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Amazon Web Services
 
DAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudDAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudAmazon Web Services
 
WIN302-Deep Dive on Active Directory From One to Many AWS Regions
WIN302-Deep Dive on Active Directory From One to Many AWS RegionsWIN302-Deep Dive on Active Directory From One to Many AWS Regions
WIN302-Deep Dive on Active Directory From One to Many AWS RegionsAmazon Web Services
 
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdf
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdfWIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdf
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdfAmazon Web Services
 

Similar to Serverless Applications at Global Scale with Multi-Regional Deployments - AWS Online Tech Talks (20)

SRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsSRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless Applications
 
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...
MBL204_Architecting Cost-Effective Mobile Backends for Scale, Security, and P...
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
 
Migrating to Amazon RDS with Database Migration Service:
Migrating to Amazon RDS with Database Migration Service:Migrating to Amazon RDS with Database Migration Service:
Migrating to Amazon RDS with Database Migration Service:
 
Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...
 
Building Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech TalksBuilding Serverless Websites with Lambda@Edge - AWS Online Tech Talks
Building Serverless Websites with Lambda@Edge - AWS Online Tech Talks
 
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaScale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
 
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...
Amazon.com - Replacing 100s of Oracle DBs with Just One: DynamoDB - ARC406 - ...
 
ATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing Operations
 
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveGPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
 
Introduction to AWS for Mobile Developers
Introduction to AWS for Mobile DevelopersIntroduction to AWS for Mobile Developers
Introduction to AWS for Mobile Developers
 
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)
如何以 serverless 架構打造快速回應客戶需求的零售情境 (Level: 200)
 
What’s New in Amazon RDS for Open-Source and Commercial Databases:
What’s New in Amazon RDS for Open-Source and Commercial Databases: What’s New in Amazon RDS for Open-Source and Commercial Databases:
What’s New in Amazon RDS for Open-Source and Commercial Databases:
 
Intro To AWS for Mobile Developers: Collision 2018
Intro To AWS for Mobile Developers: Collision 2018Intro To AWS for Mobile Developers: Collision 2018
Intro To AWS for Mobile Developers: Collision 2018
 
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
Self-Service Analytics with AWS Big Data and Tableau - ARC217 - re:Invent 2017
 
DAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudDAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the Cloud
 
WIN302-Deep Dive on Active Directory From One to Many AWS Regions
WIN302-Deep Dive on Active Directory From One to Many AWS RegionsWIN302-Deep Dive on Active Directory From One to Many AWS Regions
WIN302-Deep Dive on Active Directory From One to Many AWS Regions
 
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdf
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdfWIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdf
WIN302-Deep Dive on Active Directory From One to Many AWS Regions.pdf
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Serverless Applications at Global Scale with Multi-Regional Deployments - AWS Online Tech Talks

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Magnus Bjorkman, AWS Solution Architect Stefano Buliani, AWS Specialist Solution Architect December 4, 2017 Tech Talk: Serverless Applications at Global Scale with Multi-Regional Deployments
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHAT TO EXPECT FROM THE SESSION • FOOD FOR THOUGHT – a real world serverless application • Why go multi-region? • Decision tree – do even need to go multi-region? • One service at a time – routing and data replication concepts: • Browsing catalog • Updating catalog • Receiving orders • Summary
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Example Application
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “FOOD-FOR-THOUGHT” • Order food from any restaurant near you and get it delivered at your home • Store and browse restaurant menu items • Accept orders and process payments • Company doing business through-out North America and Europe • Customers should see low latency and high-performance at either continent. • Very high peak to average ratio of traffic around meal times • A highly fault-tolerant system is critical as reputational and revenue loss would be significant for an outage during those hours Photo by Brigitte Tohm on Unsplash
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BENEFITS OF LAMBDA AND SERVERLESS No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHY ARE “FOOD-FOR-THOUGHT” GOING MULTI-REGION? Data Sovereignty Increased Fault Tolerance Improved Latency and Performance
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What “food-for-thought” should consider when going multi-region?
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “FOOD-FOR-THOUGHT” – 3 KEY SERVICES Browse Catalog • View Restaurants • View Menus Submit Order • Order Processing • Payment Processing • Order Confirmation Update Catalog • Add, Update and Remove Restaurants • Add, Update and Remove Menus Customer Administrator
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DOES IT NEED TO BE MULTI-REGION? Core to business • Is this service truly core to our business? • How does this service access persistent storage? Multi-Region DNS routing Single Region Scheduled Replication Master/ Master Near Real-Time Eventual Consistency from Master Copy Master/ Slave Read-Only Read-Write
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. HOW MUCH WILL THIS COST? • Lambda and API Gateway only charge when code executes – traffic is the same, price is the same, not matter how many regions • Database and file storage will incur additional charges, for fully redundant services your costs increase • Data transfer out to internet costs can vary depending on the region
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MONITORING AND LOGGING • Monitoring • Fine-grained monitoring within the region • Enough monitoring from outside region to detect issue in region, especially with monitoring system • Logging • Consider replicating logs if they are critical to operations
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DATA SOVEREIGNTY • For data under purview of Data Sovereignty laws: • Implement requirements into application code and do not solely rely on routing features like geographic routing in Route 53 • Consider using home regions for users and make sure that the code/data is always executed/stored in that particular region for that particular user. • Use separate Cognito User Pools in each region
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Browsing and updating catalog
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BROWSING AND UPDATING CATALOG • Availability: • It is critical to be able to browse the catalog so customers can create orders. • It is less critical to be able to update the catalog. • Consistency: • It is required to have at least eventual read consistency. • External Dependencies: • None
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BROWSING THE CATALOG Core to business • Is this service truly core to our business? • YES – we need the catalog in order to accept orders • How does this service access persistent storage? • Data replicated to all regions from master copy Multi-Region DNS routing Single Region Scheduled Replication Master/ Master Near Real-Time Eventual Consistency from Master Copy Master/ Slave Read-Only Read-Write
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. UPDATING THE CATALOG Core to business • Is this service truly core to our business? • NO – even if the master region is down we can still accept orders. • The architectural complexity of master/master replication is not worth the return. Multi-Region DNS routing Single Region Scheduled Replication Master/ Master Near Real-Time Eventual Consistency from Master Copy Master/ Slave Read-Only Read-Write
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BROWSING CATALOG - ARCHITECTURE us-west-2 us-east-1 Amazon Route 53 mobile client Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon API Gateway AWS Lambda Amazon DynamoDB
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BROWSING CATALOG – ARCHITECTURE HIGHLIGHTS • Active-Active multi-regional API • Deploy same stack to multiple regions • Read-Only. Access DynamoDB tables in local region • Optional: For public and content more static in nature, put CloudFront in front of API.
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. API GATEWAY: REGIONAL ENDPOINTS • Endpoint configuration types • Edge optimized • Regional • Endpoint configuration types are applicable for both Custom Domain Names as well as APIs • Regional Endpoints: Custom domains are unique per region
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MULTI-REGION API GATEWAY SETUP • Endpoints in AWS Regions • Amazon Route 53 Routing (e.g. Latency, Geolocation) • Multi-Region Backends • Active-Active us-west-2 us-east-1 mobile client Amazon Route 53 API Endpoint API Endpoint Custom Domain Name Endpoint Custom Domain Name Endpoint Amazon API Gateway AWS Lambda Amazon API Gateway AWS Lambda
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. FAIL-OVER ACROSS REGIONS WITH API GATEWAY • Amazon Route 53 health checks • Provide a path that does a deep ping us-west-2 us-east-1 mobile client Amazon Route 53 API Endpoint API Endpoint Custom Domain Name Endpoint Custom Domain Name Endpoint Amazon API Gateway AWS Lambda Amazon API Gateway AWS Lambda
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. UPDATING CATALOG - ARCHITECTURE us-west-2 us-east-1 mobile client Amazon Route 53 Amazon API Gateway AWS Lambda Amazon DynamoDB
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. UPDATING CATALOG – ARCHITECTURE HIGHLIGHTS • Single-Region API. Updates are lower criticality than reads. Graceful degradation. • Data availability is critical for “Browse Catalog” use case. Replicate to other regions using DynamoDB streams. • Simplify • No data conflicts • No split brain
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MASTER/SLAVE REPLICATION WITH LAMBDA for record in event['Records']: print(record['eventID']) print(record['eventName']) print("DynamoDB Record: ” + json.dumps(record['dynamodb'], indent=2)) if (record['eventName'] == 'INSERT') or (record['eventName'] == 'MODIFY'): client.put_item(TableName=resource_properties['TargetDDB'], Item=record['dynamodb']['NewImage']) elif record['eventName'] == 'REMOVE': client.delete_item(TableName=resource_properties['TargetDDB'], Key=record['dynamodb']['Keys']) us-west-2 us-east-1 AWS Lambda Amazon DynamoDB AWS Lambda Amazon DynamoDB
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Submit order
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SUBMIT ORDER • Availability: • It is critical to be able to write new orders. • It is critical to be able to read and update existing orders. • Consistency: • It is required to have at least eventual read consistency for status of existing orders. • It is required to have strong consistency for read-before- write. • External Dependencies: • Payment System
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DECISION TREE Core to business • Is this service truly core to our business? • YES – it’s our primary revenue source • How does this service access persistent storage? • Each order has a master region. Orders are replicated but can only be modified in their master region. Multi-Region DNS routing Single Region Scheduled Replication Master/ Master Near Real-Time Eventual Consistency from Master Copy Master/ Slave Read-Only Read-Write
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SUBMIT ORDER – ALMOST MASTER / MASTER • True master/master replication is very hard: • Multi-region ACID transactions are impractical • Orders have a master region • Writes always go to the master region • Reads for processing can happen in any region • Client logic to ensure updates always go to the master region • Other regions should refuse to modify the order if they receive a request
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHY HOME REGION IF MULTI-MASTER IS POSSIBLE • Multi-master is very complex – chances of bugs are higher • Eventual consistency in reads can create a frustrating customer experience – I don’t know what the true state of my order is • Erodes customer trust quickly • Losing an entire region is highly unlikely, much less likely than order state being inconsistent across the two regions
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. APPLICATION STATE – CLIENT SIDE us-west-2 us-east-1 Amazon Route 53 1. Client uses the DNS- balanced endpoint to create an order 2. Region creates the order and sets itself as the master Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon API Gateway AWS Lambda Amazon DynamoDB
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. HOME REGION REPLICATION • Each order/record has a home region. Only write to home region. • Read from home region unless not available. • Mark initial record for replication to avoid circular updates. us-west-2 us-east-1 orderId homeRegion userId 1234 us-east-1 9012 5678 us-west-2 3456 Update Lambda Replication Lambda
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. APPLICATION STATE – CLIENT SIDE us-west-2 us-east-1 Amazon Route 53 3. Client addresses home region Directly to update order 4. Once written, any region can process the order Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon API Gateway AWS Lambda Amazon DynamoDB
  • 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SUBMIT ORDER - ARCHITECTURE us-west-2 us-east-1 mobile client Amazon Route 53 Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon API Gateway AWS Lambda Amazon DynamoDB
  • 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MASTER/MASTER REPLICATION: OTHER OPTIONS • Pessimistic locking when writing to all stores. • Strong consistency • Lock contention and potential lower through-put • Lower availability • Quorum based algorithms • Eventual consistency but with reduced risk of write conflicts • At least 3 replicas • Lower availability with certain network partitions • Conflict-free replicated data type (CRDT) • Works well for certain data structure but not others • Need to define merge logic for each CRDT
  • 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SUBMIT ORDER – ARCHITECTURE HIGHLIGHTS • Active-Active Multi-Regional API • Health Checks need to include External Dependencies • Are your dependencies also multi-region? • Deploy Same Stack to Multiple Regions • Data Replication using DynamoDB Streams: • Eventual Consistency. No 2-Phase Commits • Primary key will include home region. • Client is smart about regional availability
  • 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Summary
  • 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. TAKE AWAYS • Multi-region architectures add significant complexity to your stack – think carefully about your services and whether they need to be multi region at all • Master/master replication with eventual consistency may create a worse customer experience than losing the entire order – full regional outages are highly unlikely, keep it simple! • Route53 can perform failover checks and most operation can be automated – this does not exonerate operators and developers from the job of monitoring their service. Create relevant metrics and set alarm on them.
  • 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. NEXT STEPS • Learn more from our multi-region serverless API blog post: AWS Compute Blog: Building a Multi-region Serverless Application with Amazon API Gateway and AWS Lambda • API Gateway regional endpoints give you control over your DNS records: https://docs.aws.amazon.com/apigateway/latest/developerguide/create-regional-api.html
  • 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You Magnus Bjorkman, AWS Solution Architect Stefano Buliani, AWS Specialist Solution Architect