SlideShare a Scribd company logo
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
O N L I N E - D E V C O N F Z A
Resiliency and availability design
patterns for the cloud
Cobus Bernard
Senior Developer Advocate
AmazonWeb Services
02.04.20
@cobusbernard
cobusbernard
cobusbernard
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Can you guess whatwillhappen?
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Distributed Systems are hard
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Failures areagivenand
everythingwilleventuallyfail
over time.
Werner Vogels
CTO – Amazon.com
“ “
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Resiliency:Abilityfor asystemtohandle and
eventuallyrecover from unexpected conditions
conditions
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Partialfailure mode
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why do we build resilient software systems?
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thecostof downtime
Annual Fortune
1000 application
downtime costs
(IDC)
$1.25 to
$2.5B
Average cost of a
data breach
(Ponemon
Institute)
$3.6M
Cost/hr of a
critical
application
failure (IDC)
$500K
to $1M
Average cost/hr
of downtime
(Ponemon
Institute)
$474K
Average cost per
lost or stolen
record (Ponemon
Institute)
$141
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How do we build resilient software systems?
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
People
Application
Network & Data
Infrastructure
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk aboutAvailability
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Systemavailability
Availability =
Normal Operation Time
Total Time
MTBF**
MTBF** + MTTR*
=
* Mean Time To Repair (MTTR)
**Mean Time Between Failure (MTBF)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Reading homework
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Availabilityinparallel
A = 1 – (1 – Ax)2
Part X
Part X
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Availabilityinparallel
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
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Componentredundancyincreases availability
significantly!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Global Infrastructure
• 22 Regions with 70 Availability Zones
• 5 Regions coming soon: Cape Town
Jakarta, Milan, Spain, Osaka
• 100Gbps redundant network
• 99.99% SLA
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fully-scaledAvailabilityZone
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Highlyredundant regional network
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Region and availabilityzones
Region
Availability zone a Availability zone b Availability zone c
data center
data center
data center
1 or more data centers per AZ
2 or more AZs per region (new regions min 3)
data center
data center
data center
data center
data center
data center
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How about a global architecture?
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Once upon a time …
Origin
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
And Now …
Origin
~300ms
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Origin
Improve latency for end-users
Origin
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Improve availabilityand disasterrecovery
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
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
So should we go for a global architecture?
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Perfect your regional architecture first!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about Multi-AZ
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-AZ architecture
Region
Availability zone a Availability zone b Availability zone c
Instances Instances Instances
DB Instance DB instance
standby
Elastic Load
Balancing (ELB)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-AZ architecture
Region
Availability zone a Availability zone b Availability zone c
Instances Instances Instances
DB Instance DB instance
standby
Elastic Load
Balancing (ELB)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-AZ architecture
Region
Availability zone a Availability zone b Availability zone c
Instances Instances Instances
DB Instance DB instance
standby
Elastic Load
Balancing (ELB)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-AZ architecture
Region
Availability zone a Availability zone b Availability zone c
Instances Instances Instances
DB Instance DB instance
new master
Elastic Load
Balancing (ELB)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-AZ architecture
• Enables fault-tolerant applications
• AWS regional services designed to
withstand AZ failures
• Leveraged by AWS regional
services such as Amazon S3,
Amazon DynamoDB, Amazon
Aurora, Amazon ELBs, etc.
Region
Availability zone a Availability zone b Availability zone c
Instances Instances Instances
DB Instance DB instance
standby
Elastic Load
Balancing (ELB)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about auto scaling
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto-Scaling
FixedVariable
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Availability zone 1
Auto Scaling group
AWS Region
Availability zone 2
Auto-scaling for self-healing
Elastic Load
Balancing (ELB)
X
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about the responsibility models
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSoperationalresponsibilitymodels
On-Premises Cloud
Less More
Compute Virtual Machine
EC2 Elastic Beanstalk AWS LambdaFargate
Databases MySQL MySQL on EC2
RDS MySQL RDS Aurora Aurora Serverless DynamoDB
Storage Storage
S3
Messaging ESBs
Amazon MQ Kinesis SQS / SNS
Analytics
Hadoop Hadoop on EC2 EMR Elasticsearch Service Athena
Firehose
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about databases
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Common resiliencyissueswithDatabases??
REPLICATION BACKUPSSCALING
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
AZ 1
AZ 2
AZ 3
Network
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
Storage
Node
Leader
PutItem
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
AZ 1
AZ 2
AZ 3
RR RR RR RR RR
RR RR RR RR RR
RR RR RR RR RR
Storage
Node
Leader
GetItem
Network
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon.com, Nike, Netflix, Duolingo, Lyft, Airbnb, Samsung,
Toyota, and Capital One depend on the scale and performance of
DynamoDB to support their workloads.
10 trillion requests
per day
20 million
requests per second
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Purpose-built databases
Relational Key-value Document In-memory Graph Time-series Ledger
DynamoDB NeptuneAmazon RDS
Aurora CommercialCommunity
Timestream QLDBElastiCacheDocumentDB
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Read-Writeseparation
Master Read Replica Read Replica Read Replica
Instance InstanceInstance
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DatabaseFederation
Users
DB
Products
DB
Master
(Read) Replica
Master
(Read) Replica
Instance InstanceInstance
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DatabaseSharding User ShardID
002345 A
002346 B
002347 C
002348 B
002349 A
CBA
Master
(Read) Replica
Master
(Read) Replica
Master
(Read) Replica
Instance InstanceInstance
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about backups
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Backup service
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
PreventingAccidentalTableDeletion
https://aws.amazon.com/blogs/database/preventing-accidental-table-deletion-in-dynamodb/
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
PreventingAccidentalTableDeletion (sql)
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Practice and testrecoveryfrom your backups!!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about timeouts, backoff &
retries!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Users
App
DB
Conn
Pool
INSERT
INSERT
INSERT
INSERT
What happens if the DB “slows down”?
Timeout client side Timeout backend side ??
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
User 1
App
DB
Conn
Pool
INSERT
Timeout client side = 10s Timeout backend side = default = Infinite
Retry INSERT
Retry INSERT
ERROR: Failed to get connection from pool
Retry
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
https://docs.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest.timeout
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
@timeout_decorator.timeout(5, timeout_exception=StopIteration)
def timed_get(url):
return requests.get(url)
https://pypi.org/project/timeout-decorator/
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How elsecould wehaveprevented theerror?
User 1
DB
Conn
Pool
INSERT
Retry INSERT
Retry INSERT
Retry
ERROR: Failed to get connection from pool
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
User 1
DB
Conn
Pool
INSERT
Timeout client side = 10s Timeout backend side = 10s
Wait 2s before Retry
INSERT
INSERT
Wait 4s before Retry
Wait 8s before Retry
Wait 16s before Retry
Backing off betweenretries
Releasing connectionsBackoff
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
No jitter With jitter
https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
SimpleExponentialBackoffisnotenough:AddJitter
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Example: add jitter0-1000ms
def get_item(self, url, n=1):
MAX_TRIES = 12
try:
res = requests.get(url)
except:
if n > MAX_TRIES:
return None
n += 1
time.sleep((2 ** n) + (random.randint(0, 1000) / 1000.0))
return self.get_item(url, n)
else:
return res
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Idempotent operation
No additional effect if it is called more than
once with the same input parameters.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about health checking!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Auto Scaling group
Service A
Availability zone 1
Auto Scaling group
AWS Region
Service A
Availability zone 2
Service BService B
database Email
Probing for health
Cluster
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Email
database
Shallowhealthcheck
Instance
Cache node
Cluster
Are you healthy?
yes
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
database
Shallowhealthcheck
Instance
Cache node
Cluster
Are you healthy?
yes
Email
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Email
database
Deep healthcheck
Instance
Cache node
Cluster
Are you healthy?
yes
Are you healthy?
yes
yes
yes
yes
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Email
database
Deep healthcheck
Instance
Cache node
Cluster
Are you healthy?
no
Are you healthy?
no
yes
yes
yes
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Prioritize shallow health checks during
hard times.
Cache.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk about load shedding.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cheaply reject excess work
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Be careful when selecting the right metric
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Don’tbeoverlyoptimisticandtakeonmorethanyoucan.
Findanoperationalmetrictorejectwhatyoucannottakein.
Favorcachedandstaticcontent
PrioritizeELBhealthcheck(shallow)pings
Inanoverloadsituationyouhavepreciousresources,donotletany
ofitgotowaste.
Load Shedding
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Let’s talk aboutresiliency (chaos) engineering
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fire Drills
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Chaosengineering
https://github.com/Netflix/SimianArmy
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Chaos Engineeringis the discipline of
experimentingon a distributedsystem
in orderto buildconfidence in the system’s
capabilitytowithstand turbulentconditionsin
production.”
http://principlesofchaos.org
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Failureinjection
• Start small & build confidence
• Application level
• Host failure
• Resource attacks (CPU, memory, …)
• Network attacks (dependencies, latency, …)
• Region attacks
• “Paul” attack
https://www.gremlin.comhttps://github.com/Netflix/SimianArmy https://chaostoolkit.org
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
STEADY
STATE
HYPOTHESIS
RUN
EXPERIMENT
VERIFY
FIX!
PhasesofChaosEngineering
Thank you!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cobus Bernard
Senior DeveloperAdvocate
Amazon Web Services
O N L I N E - D E V C O N F Z A
@cobusbernard
cobusbernard
cobusbernard

More Related Content

PPTX
AWS SSA Webinar 7 - Getting Started on AWS
PPTX
DevConfZA 2020 : Automating your cloud: What are the building blocks
PPTX
AWS Startup Garage - Building your MVP on AWS
PPTX
2019-11-05 AWS Pretoria Meetup - Setting up your first environment and adding...
PPTX
AWS SSA Webinar 4 - Building out your multi-account infrastructure
PPTX
2019-11-09 DevOpsNG - What I've learned from DevOps
PPTX
AWSome Day Brasil - Março 2020
PDF
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
AWS SSA Webinar 7 - Getting Started on AWS
DevConfZA 2020 : Automating your cloud: What are the building blocks
AWS Startup Garage - Building your MVP on AWS
2019-11-05 AWS Pretoria Meetup - Setting up your first environment and adding...
AWS SSA Webinar 4 - Building out your multi-account infrastructure
2019-11-09 DevOpsNG - What I've learned from DevOps
AWSome Day Brasil - Março 2020
20190731 Black Belt Online Seminar Amazon ECS Deep Dive

What's hot (15)

PPTX
AWS SSA Webinar - Cost optimisation on AWS
PPTX
AWS SSA Webinar 8 - Getting Started on AWS: Compute
PPTX
Deep Dive Amazon SageMaker
PDF
신입 개발자가 스타트업에서 AWS로 살아남는 이야기 - 조용진, 모두의 캠퍼스 :: AWS Summit Seoul 2019
PDF
20190306 AWS Black Belt Online Seminar Amazon EC2 スポットインスタンス
PDF
20180724 AWS Black Belt Online Seminar Amazon Elastic Container Service for K...
PDF
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
PDF
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...
PDF
20190911 AWS Black Belt Online Seminar AWS Batch
PDF
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
PDF
서버리스 기반 콘텐츠 추천 서비스 만들기 - 이상현, Vingle :: AWS Summit Seoul 2019
PDF
20191023 AWS Black Belt Online Seminar Amazon EMR
PDF
AWS 기반 지속 가능한 데이터 분석 플랫폼 구축하기 - 소성운, 지그재그 :: AWS Summit Seoul 2019
PDF
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
PDF
Perfecting the Media Workflow Experience on AWS - Ben Masek, 월드와이드 미디어 사업개발 헤...
AWS SSA Webinar - Cost optimisation on AWS
AWS SSA Webinar 8 - Getting Started on AWS: Compute
Deep Dive Amazon SageMaker
신입 개발자가 스타트업에서 AWS로 살아남는 이야기 - 조용진, 모두의 캠퍼스 :: AWS Summit Seoul 2019
20190306 AWS Black Belt Online Seminar Amazon EC2 スポットインスタンス
20180724 AWS Black Belt Online Seminar Amazon Elastic Container Service for K...
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 ...
20190911 AWS Black Belt Online Seminar AWS Batch
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
서버리스 기반 콘텐츠 추천 서비스 만들기 - 이상현, Vingle :: AWS Summit Seoul 2019
20191023 AWS Black Belt Online Seminar Amazon EMR
AWS 기반 지속 가능한 데이터 분석 플랫폼 구축하기 - 소성운, 지그재그 :: AWS Summit Seoul 2019
Orchestrating containers on AWS | AWS Summit Tel Aviv 2019
Perfecting the Media Workflow Experience on AWS - Ben Masek, 월드와이드 미디어 사업개발 헤...
Ad

Similar to DevConf 2020: Resiliency and availability design patterns for the cloud (20)

PPTX
AWS DevDay Berlin - Resiliency and availability design patterns for the cloud
PPTX
AWS DevDay Vienna - Resiliency and availability design patterns for the cloud
PPTX
AWS DevDay Cologne - Resiliency and availability design patterns for the cloud
PDF
"Resiliency and Availability Design Patterns for the Cloud", Sebastien Storma...
PPTX
Building Global Multi-Region, Active-Active Serverless Backends I AWS Dev Day...
PPTX
Building a Multi-Region, Active-Active Serverless Backends.
PDF
AWS DevDay Berlin 2019 - Going Global With Serverless
PDF
Architecting for the cloud cloud providers
PPTX
AWS Distilled
PPTX
AWS Session.pptx
PDF
"How to build a global serverless service", Alex Casalboni, AWS Dev Day Kyiv ...
PPT
Amazon web services a quick introduction
PPT
Amazon web services: A Quick Introduction from Cloudreach
PPTX
Aws best practices
PPTX
Journey Towards Scaling Your API to 10 Million Users
PDF
Understand the Cloud Computing and the future career possibilities
PDF
AWS-services.pdf
PDF
AWSome Day Lisboa 2017
PDF
Uses, considerations, and recommendations for AWS
PDF
20200513 - CloudComputing UCU
AWS DevDay Berlin - Resiliency and availability design patterns for the cloud
AWS DevDay Vienna - Resiliency and availability design patterns for the cloud
AWS DevDay Cologne - Resiliency and availability design patterns for the cloud
"Resiliency and Availability Design Patterns for the Cloud", Sebastien Storma...
Building Global Multi-Region, Active-Active Serverless Backends I AWS Dev Day...
Building a Multi-Region, Active-Active Serverless Backends.
AWS DevDay Berlin 2019 - Going Global With Serverless
Architecting for the cloud cloud providers
AWS Distilled
AWS Session.pptx
"How to build a global serverless service", Alex Casalboni, AWS Dev Day Kyiv ...
Amazon web services a quick introduction
Amazon web services: A Quick Introduction from Cloudreach
Aws best practices
Journey Towards Scaling Your API to 10 Million Users
Understand the Cloud Computing and the future career possibilities
AWS-services.pdf
AWSome Day Lisboa 2017
Uses, considerations, and recommendations for AWS
20200513 - CloudComputing UCU
Ad

More from Cobus Bernard (20)

PPTX
London Microservices Meetup: Lessons learnt adopting microservices
PPTX
AWS SSA Webinar 34 - Getting started with databases on AWS - Managing DBs wit...
PPTX
AWS SSA Webinar 33 - Getting started with databases on AWS Amazon DynamoDB
PPTX
AWS SSA Webinar 32 - Getting Started with databases on AWS: Choosing the righ...
PPTX
AWS SSA Webinar 30 - Getting Started with AWS - Infrastructure as Code - Terr...
PPTX
AWS SSA Webinar 28 - Getting Started with AWS - Infrastructure as Code
PPTX
AWS Webinar 24 - Getting Started with AWS - Understanding DR
PPTX
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
PPTX
AWS SSA Webinar 21 - Getting Started with Data lakes on AWS
PDF
AWS SSA Webinar 20 - Getting Started with Data Warehouses on AWS
PPTX
AWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: Services
PPTX
AWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: Data
PPTX
AWS EMEA Online Summit - Live coding with containers
PPTX
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
PPTX
AWS SSA Webinar 17 - Getting Started on AWS with Amazon RDS
PPTX
AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2
PPTX
AWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKS
PPTX
AWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECS
PPTX
AWS SSA Webinar 11 - Getting started on AWS: Security
PPTX
AWS SSA Webinar 12 - Getting started on AWS with Containers
London Microservices Meetup: Lessons learnt adopting microservices
AWS SSA Webinar 34 - Getting started with databases on AWS - Managing DBs wit...
AWS SSA Webinar 33 - Getting started with databases on AWS Amazon DynamoDB
AWS SSA Webinar 32 - Getting Started with databases on AWS: Choosing the righ...
AWS SSA Webinar 30 - Getting Started with AWS - Infrastructure as Code - Terr...
AWS SSA Webinar 28 - Getting Started with AWS - Infrastructure as Code
AWS Webinar 24 - Getting Started with AWS - Understanding DR
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
AWS SSA Webinar 21 - Getting Started with Data lakes on AWS
AWS SSA Webinar 20 - Getting Started with Data Warehouses on AWS
AWS SSA Webinar 19 - Getting Started with Multi-Region Architecture: Services
AWS SSA Webinar 18 - Getting Started with Multi-Region Architecture: Data
AWS EMEA Online Summit - Live coding with containers
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS SSA Webinar 17 - Getting Started on AWS with Amazon RDS
AWS SSA Webinar 16 - Getting Started on AWS with Amazon EC2
AWS SSA Webinar 15 - Getting started on AWS with Containers: Amazon EKS
AWS SSA Webinar 13 - Getting started on AWS with Containers: Amazon ECS
AWS SSA Webinar 11 - Getting started on AWS: Security
AWS SSA Webinar 12 - Getting started on AWS with Containers

Recently uploaded (20)

PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
artificial intelligence overview of it and more
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
DOCX
Unit-3 cyber security network security of internet system
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPT
tcp ip networks nd ip layering assotred slides
PDF
Testing WebRTC applications at scale.pdf
PPTX
innovation process that make everything different.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PptxGenJS_Demo_Chart_20250317130215833.pptx
artificial intelligence overview of it and more
introduction about ICD -10 & ICD-11 ppt.pptx
Unit-3 cyber security network security of internet system
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Module 1 - Cyber Law and Ethics 101.pptx
Cloud-Scale Log Monitoring _ Datadog.pdf
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
tcp ip networks nd ip layering assotred slides
Testing WebRTC applications at scale.pdf
innovation process that make everything different.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
SASE Traffic Flow - ZTNA Connector-1.pdf
WebRTC in SignalWire - troubleshooting media negotiation
Unit-1 introduction to cyber security discuss about how to secure a system
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx

DevConf 2020: Resiliency and availability design patterns for the cloud

  • 1. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. O N L I N E - D E V C O N F Z A Resiliency and availability design patterns for the cloud Cobus Bernard Senior Developer Advocate AmazonWeb Services 02.04.20 @cobusbernard cobusbernard cobusbernard
  • 2. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 3. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Can you guess whatwillhappen?
  • 4. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Distributed Systems are hard
  • 5. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Failures areagivenand everythingwilleventuallyfail over time. Werner Vogels CTO – Amazon.com “ “
  • 6. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Resiliency:Abilityfor asystemtohandle and eventuallyrecover from unexpected conditions conditions
  • 7. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Partialfailure mode
  • 8. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why do we build resilient software systems?
  • 9. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thecostof downtime Annual Fortune 1000 application downtime costs (IDC) $1.25 to $2.5B Average cost of a data breach (Ponemon Institute) $3.6M Cost/hr of a critical application failure (IDC) $500K to $1M Average cost/hr of downtime (Ponemon Institute) $474K Average cost per lost or stolen record (Ponemon Institute) $141
  • 10. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. How do we build resilient software systems?
  • 11. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. People Application Network & Data Infrastructure
  • 12. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk aboutAvailability
  • 13. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Systemavailability Availability = Normal Operation Time Total Time MTBF** MTBF** + MTTR* = * Mean Time To Repair (MTTR) **Mean Time Between Failure (MTBF)
  • 14. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Reading homework
  • 15. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Availabilityinparallel A = 1 – (1 – Ax)2 Part X Part X
  • 16. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Availabilityinparallel 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
  • 17. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Componentredundancyincreases availability significantly!
  • 18. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Global Infrastructure • 22 Regions with 70 Availability Zones • 5 Regions coming soon: Cape Town Jakarta, Milan, Spain, Osaka • 100Gbps redundant network • 99.99% SLA
  • 19. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Fully-scaledAvailabilityZone
  • 20. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Highlyredundant regional network
  • 21. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Region and availabilityzones Region Availability zone a Availability zone b Availability zone c data center data center data center 1 or more data centers per AZ 2 or more AZs per region (new regions min 3) data center data center data center data center data center data center
  • 22. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. How about a global architecture?
  • 23. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Once upon a time … Origin
  • 24. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. And Now … Origin ~300ms
  • 25. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Origin Improve latency for end-users Origin
  • 26. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Improve availabilityand disasterrecovery 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
  • 27. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. So should we go for a global architecture?
  • 28. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Perfect your regional architecture first!
  • 29. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about Multi-AZ
  • 30. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-AZ architecture Region Availability zone a Availability zone b Availability zone c Instances Instances Instances DB Instance DB instance standby Elastic Load Balancing (ELB)
  • 31. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-AZ architecture Region Availability zone a Availability zone b Availability zone c Instances Instances Instances DB Instance DB instance standby Elastic Load Balancing (ELB)
  • 32. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-AZ architecture Region Availability zone a Availability zone b Availability zone c Instances Instances Instances DB Instance DB instance standby Elastic Load Balancing (ELB)
  • 33. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-AZ architecture Region Availability zone a Availability zone b Availability zone c Instances Instances Instances DB Instance DB instance new master Elastic Load Balancing (ELB)
  • 34. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-AZ architecture • Enables fault-tolerant applications • AWS regional services designed to withstand AZ failures • Leveraged by AWS regional services such as Amazon S3, Amazon DynamoDB, Amazon Aurora, Amazon ELBs, etc. Region Availability zone a Availability zone b Availability zone c Instances Instances Instances DB Instance DB instance standby Elastic Load Balancing (ELB)
  • 35. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about auto scaling
  • 36. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Auto-Scaling FixedVariable
  • 37. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Availability zone 1 Auto Scaling group AWS Region Availability zone 2 Auto-scaling for self-healing Elastic Load Balancing (ELB) X
  • 38. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about the responsibility models
  • 39. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSoperationalresponsibilitymodels On-Premises Cloud Less More Compute Virtual Machine EC2 Elastic Beanstalk AWS LambdaFargate Databases MySQL MySQL on EC2 RDS MySQL RDS Aurora Aurora Serverless DynamoDB Storage Storage S3 Messaging ESBs Amazon MQ Kinesis SQS / SNS Analytics Hadoop Hadoop on EC2 EMR Elasticsearch Service Athena Firehose
  • 40. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about databases
  • 41. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Common resiliencyissueswithDatabases?? REPLICATION BACKUPSSCALING
  • 42. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 43. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR AZ 1 AZ 2 AZ 3 Network RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR Storage Node Leader PutItem
  • 44. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR AZ 1 AZ 2 AZ 3 RR RR RR RR RR RR RR RR RR RR RR RR RR RR RR Storage Node Leader GetItem Network
  • 45. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon.com, Nike, Netflix, Duolingo, Lyft, Airbnb, Samsung, Toyota, and Capital One depend on the scale and performance of DynamoDB to support their workloads. 10 trillion requests per day 20 million requests per second
  • 46. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Purpose-built databases Relational Key-value Document In-memory Graph Time-series Ledger DynamoDB NeptuneAmazon RDS Aurora CommercialCommunity Timestream QLDBElastiCacheDocumentDB
  • 47. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Read-Writeseparation Master Read Replica Read Replica Read Replica Instance InstanceInstance
  • 48. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. DatabaseFederation Users DB Products DB Master (Read) Replica Master (Read) Replica Instance InstanceInstance
  • 49. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. DatabaseSharding User ShardID 002345 A 002346 B 002347 C 002348 B 002349 A CBA Master (Read) Replica Master (Read) Replica Master (Read) Replica Instance InstanceInstance
  • 50. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about backups
  • 51. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 52. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Backup service
  • 53. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. PreventingAccidentalTableDeletion https://aws.amazon.com/blogs/database/preventing-accidental-table-deletion-in-dynamodb/
  • 54. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. PreventingAccidentalTableDeletion (sql)
  • 55. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Practice and testrecoveryfrom your backups!!
  • 56. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about timeouts, backoff & retries!
  • 57. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Users App DB Conn Pool INSERT INSERT INSERT INSERT What happens if the DB “slows down”? Timeout client side Timeout backend side ??
  • 58. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. User 1 App DB Conn Pool INSERT Timeout client side = 10s Timeout backend side = default = Infinite Retry INSERT Retry INSERT ERROR: Failed to get connection from pool Retry
  • 59. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. https://docs.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest.timeout
  • 60. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 61. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
  • 62. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. @timeout_decorator.timeout(5, timeout_exception=StopIteration) def timed_get(url): return requests.get(url) https://pypi.org/project/timeout-decorator/
  • 63. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. How elsecould wehaveprevented theerror? User 1 DB Conn Pool INSERT Retry INSERT Retry INSERT Retry ERROR: Failed to get connection from pool
  • 64. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. User 1 DB Conn Pool INSERT Timeout client side = 10s Timeout backend side = 10s Wait 2s before Retry INSERT INSERT Wait 4s before Retry Wait 8s before Retry Wait 16s before Retry Backing off betweenretries Releasing connectionsBackoff
  • 65. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. No jitter With jitter https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ SimpleExponentialBackoffisnotenough:AddJitter
  • 66. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Example: add jitter0-1000ms def get_item(self, url, n=1): MAX_TRIES = 12 try: res = requests.get(url) except: if n > MAX_TRIES: return None n += 1 time.sleep((2 ** n) + (random.randint(0, 1000) / 1000.0)) return self.get_item(url, n) else: return res
  • 67. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Idempotent operation No additional effect if it is called more than once with the same input parameters.
  • 68. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about health checking!
  • 69. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Auto Scaling group Service A Availability zone 1 Auto Scaling group AWS Region Service A Availability zone 2 Service BService B database Email Probing for health Cluster
  • 70. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Email database Shallowhealthcheck Instance Cache node Cluster Are you healthy? yes
  • 71. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. database Shallowhealthcheck Instance Cache node Cluster Are you healthy? yes Email
  • 72. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Email database Deep healthcheck Instance Cache node Cluster Are you healthy? yes Are you healthy? yes yes yes yes
  • 73. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Email database Deep healthcheck Instance Cache node Cluster Are you healthy? no Are you healthy? no yes yes yes
  • 74. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Prioritize shallow health checks during hard times. Cache.
  • 75. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk about load shedding.
  • 76. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 77. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 78. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Cheaply reject excess work
  • 79. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 80. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Be careful when selecting the right metric
  • 81. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Don’tbeoverlyoptimisticandtakeonmorethanyoucan. Findanoperationalmetrictorejectwhatyoucannottakein. Favorcachedandstaticcontent PrioritizeELBhealthcheck(shallow)pings Inanoverloadsituationyouhavepreciousresources,donotletany ofitgotowaste. Load Shedding
  • 82. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Let’s talk aboutresiliency (chaos) engineering
  • 83. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Fire Drills
  • 84. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Chaosengineering https://github.com/Netflix/SimianArmy
  • 85. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Chaos Engineeringis the discipline of experimentingon a distributedsystem in orderto buildconfidence in the system’s capabilitytowithstand turbulentconditionsin production.” http://principlesofchaos.org
  • 86. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Failureinjection • Start small & build confidence • Application level • Host failure • Resource attacks (CPU, memory, …) • Network attacks (dependencies, latency, …) • Region attacks • “Paul” attack https://www.gremlin.comhttps://github.com/Netflix/SimianArmy https://chaostoolkit.org
  • 87. © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. STEADY STATE HYPOTHESIS RUN EXPERIMENT VERIFY FIX! PhasesofChaosEngineering
  • 88. Thank you! © 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved. Cobus Bernard Senior DeveloperAdvocate Amazon Web Services O N L I N E - D E V C O N F Z A @cobusbernard cobusbernard cobusbernard