© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Adrian Hornsby, Technical Evangelist @ AWS
Twitter: @adhorn
10 Lessons from 10 years of AWS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A bit about me
Technical Evangelist, Developer Advocate,
… Software Engineer
My home is in Finland
Previously:
• Solutions Architect @AWS
• Lead Cloud Architect, Backend developer, … @Dreambroker
• Director of Engineering, Software Engineer, DevOps, ... @Hdm
• Researcher @Nokia Research Center
• and a bunch of other stuff.
Love climbing and ginger shots.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why 10 lessons?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EMBRACE FAILURE
1
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“It is not failure itself that holds you
back; it is the fear of failure that
paralyzes you.”
Brian Tracy
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
"organizations which design systems ... are
constrained to produce designs which are
copies of the communication structures of
these organizations."
M. Conway
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
LOCAL STATE IS A CLOUD ANTI-PATTERN
2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Transient state
do not belong in
the database.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IMMUTABLE INFRASTRUCTURE
3
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Immutable components are replaced for
every deployment, rather than being
updated in-place.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Immutable Infrastructure
• No updates on live systems
• Always start from a new instance being provisioned
• Deploy the new software
• Test in different environments (dev, staging)
• Deploy to prod (inactive)
• Change references (DNS or Load Balancer)
• Keep old version around (inactive)
• Fast rollback if things go wrong
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INFRASTRUCTURE AS CODE
4
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Infrastructure as Code
• Template of the infrastructure in code.
• Version controlled infrastructure.
• Repeatable template.
• Testable infrastructure.
• Automate it!
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ASYNCHRONOUS AND EVENT-DRIVEN PATTERNS
WILL HELP YOU SCALE
5
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Message passing for async. patterns
A
Queue
B
A
Queue
BListener
Pub-Sub
SNS, SQS, Redis, RabbitMQ
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Async. Architecture (part 1)
Web
Instances
Worker
Instance
Worker
Instance
Queue
API
Instance
API
Instance
API
Instance
API: {DO foo}
PUT JOB: {JobID: 0001, Task: DO foo}
API: {JobID: 0001}
GET JOB: {JobID: 0001, Task: DO foo}
ElastiCache
Result:
{
JobID: 0001,
Result: bar
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Async. Architecture (part 2)
Worker
Instance
Worker
Instance
Queue
API
Instance
API
Instance
API
Instance
ElastiCache
Amazon SNS
Push Notification
User
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
RDS DB Instance
Active (Multi-AZ)
Availability Zone
Elastic Load
Balancer
Web
Instance
Web
Instance
Amazon
Route 53User
Amazon S3
Amazon
Cloudfront
ElastiCache
Worker
Instance
Worker
Instance
Decoupling
Queue Amazon SNS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Event driven pattern
A B CEvent on B by A triggers C
Invocation
Lambda functions
Action
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How Lambda works
S3 event
notifications
DynamoDB
Streams
Kinesis
events
Cognito
events
SNS
events
Custom
events
CloudTrail
events
LambdaDynamoDB
Kinesis S3
Any custom
Invoked in response to events
- Changes in data
- Changes in state
Redshift
SNS
Access any service,
including your own
Such as…
Lambda functions
CloudWatch
events
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Event-driven using Lambda
AWS Lambda:
Resize Images
Users upload photos
S3:
Source Bucket
S3:
Destination Bucket
Triggered on
PUTs
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DON’T FORGET TO SCALE THE DATABASE
(SHARDING TO THE RESCUE)
6
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Read / Write Sharding
RDS DB Instance
Read Replica
App
Instance
App
Instance
App
Instance
RDS DB Instance
Master (Multi-AZ)
RDS DB Instance
Read Replica
RDS DB Instance
Read Replica
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Database Federation
Users
DB
Products
DB
App
Instance
App
Instance
App
Instance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Database Sharding
User ShardID
002345 A
002346 B
002347 C
002348 B
002349 A
CBA
App
Instance
App
Instance
App
Instance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MEASURE, MEASURE, AND MEASURE
7
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Measure __everything__
• Nurture a culture of measuring everything.
• Make it easy to measure.
• Setup alarms and escalation paths.
• Learn and work to automate responses.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DynamoDB at Amazon
“A deep dive on how we were using our existing
databases revealed that they were frequently not used
for their relational capabilities. About 70 percent of
operations were of the key-value kind, where only a
primary key was used and a single row would be returned.
About 20 percent would return a set of rows, but still
operate on only a single table.”
Werner Vogels
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Measuring without Operational Targets is often
Useless
• How can you progress if you have no targets?
• Load test
• Set target and make data driven decisions, not hunch
based.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
PLAN FOR THE WORST, PREPARE FOR THE
UNEXPECTED
8
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The best way to know if you
are resilient to failure is to
TEST failures.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
YOU BUILD IT, YOU RUN IT!
9
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BE HUMBLE,
LEARN FROM OTHERS, MAKE HISTORY
10
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
https://medium.com/@NetflixTechBlog
https://engineering.instagram.com/
http://www.allthingsdistributed.com/
http://highscalability.com/
https://segment.com/blog/categories/engineering/
https://reinvent.awsevents.com/
https://www.meetup.com/topics/amazon-web-services/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
RECAP
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
1. EMBRACE FAILURE
2. LOCAL STATE IS A CLOUD ANTI-PATTERN
3. IMMUTABLE INFRASTRUCTURE
4. INFRASTRUCTURE AS CODE
5. ASYNCHRONOUS AND EVENT-DRIVEN PATTERNS WILL HELP
YOU SCALE
6. DON’T FORGET TO SCALE THE DATABASE (SHARDING TO
THE RESCUE)
7. MEASURE, MEASURE, AND MEASURE
8. PLAN FOR THE WORST, PREPARE FOR THE UNEXPECTED
9. YOU BUILD IT, YOU RUN IT!
10.LEARN FROM OTHERS.
10 Lessons from 10 Years of AWS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
Questions?
Twitter: @adhorn

10 Lessons from 10 Years of AWS

  • 1.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Adrian Hornsby, Technical Evangelist @ AWS Twitter: @adhorn 10 Lessons from 10 years of AWS
  • 2.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. A bit about me Technical Evangelist, Developer Advocate, … Software Engineer My home is in Finland Previously: • Solutions Architect @AWS • Lead Cloud Architect, Backend developer, … @Dreambroker • Director of Engineering, Software Engineer, DevOps, ... @Hdm • Researcher @Nokia Research Center • and a bunch of other stuff. Love climbing and ginger shots.
  • 3.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Why 10 lessons?
  • 4.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EMBRACE FAILURE 1
  • 5.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “It is not failure itself that holds you back; it is the fear of failure that paralyzes you.” Brian Tracy
  • 6.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. "organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations." M. Conway
  • 7.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. LOCAL STATE IS A CLOUD ANTI-PATTERN 2
  • 8.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Transient state do not belong in the database.
  • 9.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. IMMUTABLE INFRASTRUCTURE 3
  • 10.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Immutable components are replaced for every deployment, rather than being updated in-place.
  • 11.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Immutable Infrastructure • No updates on live systems • Always start from a new instance being provisioned • Deploy the new software • Test in different environments (dev, staging) • Deploy to prod (inactive) • Change references (DNS or Load Balancer) • Keep old version around (inactive) • Fast rollback if things go wrong
  • 12.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. INFRASTRUCTURE AS CODE 4
  • 13.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Infrastructure as Code • Template of the infrastructure in code. • Version controlled infrastructure. • Repeatable template. • Testable infrastructure. • Automate it!
  • 14.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 15.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ASYNCHRONOUS AND EVENT-DRIVEN PATTERNS WILL HELP YOU SCALE 5
  • 16.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Message passing for async. patterns A Queue B A Queue BListener Pub-Sub SNS, SQS, Redis, RabbitMQ
  • 17.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Async. Architecture (part 1) Web Instances Worker Instance Worker Instance Queue API Instance API Instance API Instance API: {DO foo} PUT JOB: {JobID: 0001, Task: DO foo} API: {JobID: 0001} GET JOB: {JobID: 0001, Task: DO foo} ElastiCache Result: { JobID: 0001, Result: bar }
  • 18.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Async. Architecture (part 2) Worker Instance Worker Instance Queue API Instance API Instance API Instance ElastiCache Amazon SNS Push Notification User
  • 19.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. RDS DB Instance Active (Multi-AZ) Availability Zone Elastic Load Balancer Web Instance Web Instance Amazon Route 53User Amazon S3 Amazon Cloudfront ElastiCache Worker Instance Worker Instance Decoupling Queue Amazon SNS
  • 20.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Event driven pattern A B CEvent on B by A triggers C Invocation Lambda functions Action
  • 21.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. How Lambda works S3 event notifications DynamoDB Streams Kinesis events Cognito events SNS events Custom events CloudTrail events LambdaDynamoDB Kinesis S3 Any custom Invoked in response to events - Changes in data - Changes in state Redshift SNS Access any service, including your own Such as… Lambda functions CloudWatch events
  • 22.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Event-driven using Lambda AWS Lambda: Resize Images Users upload photos S3: Source Bucket S3: Destination Bucket Triggered on PUTs
  • 23.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DON’T FORGET TO SCALE THE DATABASE (SHARDING TO THE RESCUE) 6
  • 24.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Read / Write Sharding RDS DB Instance Read Replica App Instance App Instance App Instance RDS DB Instance Master (Multi-AZ) RDS DB Instance Read Replica RDS DB Instance Read Replica
  • 25.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Database Federation Users DB Products DB App Instance App Instance App Instance
  • 26.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Database Sharding User ShardID 002345 A 002346 B 002347 C 002348 B 002349 A CBA App Instance App Instance App Instance
  • 27.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MEASURE, MEASURE, AND MEASURE 7
  • 28.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Measure __everything__ • Nurture a culture of measuring everything. • Make it easy to measure. • Setup alarms and escalation paths. • Learn and work to automate responses.
  • 29.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. DynamoDB at Amazon “A deep dive on how we were using our existing databases revealed that they were frequently not used for their relational capabilities. About 70 percent of operations were of the key-value kind, where only a primary key was used and a single row would be returned. About 20 percent would return a set of rows, but still operate on only a single table.” Werner Vogels
  • 30.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Measuring without Operational Targets is often Useless • How can you progress if you have no targets? • Load test • Set target and make data driven decisions, not hunch based.
  • 31.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. PLAN FOR THE WORST, PREPARE FOR THE UNEXPECTED 8
  • 32.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 33.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. The best way to know if you are resilient to failure is to TEST failures.
  • 34.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. YOU BUILD IT, YOU RUN IT! 9
  • 35.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.
  • 36.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BE HUMBLE, LEARN FROM OTHERS, MAKE HISTORY 10
  • 37.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. https://medium.com/@NetflixTechBlog https://engineering.instagram.com/ http://www.allthingsdistributed.com/ http://highscalability.com/ https://segment.com/blog/categories/engineering/ https://reinvent.awsevents.com/ https://www.meetup.com/topics/amazon-web-services/
  • 38.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. RECAP
  • 39.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 1. EMBRACE FAILURE 2. LOCAL STATE IS A CLOUD ANTI-PATTERN 3. IMMUTABLE INFRASTRUCTURE 4. INFRASTRUCTURE AS CODE 5. ASYNCHRONOUS AND EVENT-DRIVEN PATTERNS WILL HELP YOU SCALE 6. DON’T FORGET TO SCALE THE DATABASE (SHARDING TO THE RESCUE) 7. MEASURE, MEASURE, AND MEASURE 8. PLAN FOR THE WORST, PREPARE FOR THE UNEXPECTED 9. YOU BUILD IT, YOU RUN IT! 10.LEARN FROM OTHERS. 10 Lessons from 10 Years of AWS
  • 40.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Thank you! Questions? Twitter: @adhorn