SlideShare a Scribd company logo
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Minoo Duraipandy, AWS Solution Architect
(Repeat of ARC313 from re:Invent 2016)
11/30/2016
Running Lean Architectures
How to Optimize for Cost Efficiency
Original Speakers @ re:Invent 2016
Markus Ostertag, Head of Development, Team Internet AG
Constantin Gonzalez, Principal Solutions Architect, AWS
ARC313 Running Lean Architectures: How to Optimize for Cost Efficiency
What you’ll get out of this session
• Best practices on how to lower your AWS bill
• A more scalable, robust, dynamic architecture
• More time to innovate
• Real-world customer examples
• Easy to implement
AWS pricing philosophy
Ecosystem
Global Footprint
New Features
New Services
More AWS
Usage
More
Infrastructure
Lower
Infrastructure
Costs
Reduced
Prices
More
CustomersInfrastructure
Innovation
57 price
reductions
since 2006Economies
of Scale
The Holy Grail of Cost Optimization
“Pay for what you use.”
“Pay as little as possible
for what we use.”
“Pay for what you need.”
AWS TCO calculator
AWS simple monthly calculator
AWS billing alerts
AWS billing console
AWS Trusted Advisor
aws.amazon.com/premiumsupport/trustedadvisor/
Free with Business or Enterprise Support
Free Trusted Advisor Trial!
• Free trial begins on 12/6/16
• Runs for 30 days
• Full suite of checks and best practice
recommendations available
• For customers not already on
business/enterprise support plans
• No action required:
Just log in and start using!
https://console.aws.amazon.com/trustedadvisor
Reserved Instances
Reserved Instances basics
1y RI
Break even
3y RI
Break even
Reserved Instances – customer usage (large
German software company)
Use regional benefit
Change existing Reserved Instances to scope “region”
Capacity reservation decoupled from cost optimization
Convertible Reserved Instances
Use case: “(Very) Long running, but flexible”
Architecture Goals
“Avoid waste as much
as possible.”
Turn off unused instances
• Developer, test, training instances
• Use simple instance start and stop
• Or tear down and build up all together
using AWS CloudFormation
• Instances are disposable!
Customer example
Monday Friday End of Vacation Season
35% saved
Automate, automate, automate
• AWS SDKs
• AWS CLI
• AWS CloudFormation
• AWS OpsWorks
• Netflix Janitor Monkey
• Cloudlytics EC2 Scheduler
• Auto Scaling
How Auto Scaling works
AWS CloudFormation Example Launch Configuration
"LaunchConfig": {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
… packages, sources, files, services …
}
}
},
"Properties": {
"ImageId" : "ami-149f7863",
"InstanceType" : "m1.small",
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
"KeyName" : "MySSHKey",
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -vn",
… your user data script …
]]}}
}
}
AWS CloudFormation Example
Auto Scaling Group Definition
"WebServerGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [
"us-east-1a",
"us-east-1b",
"us-east-1c",
],
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
"MinSize" : “3",
"MaxSize" : “6",
"DesiredCapacity" : “3",
"LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]
}
}
Align Resources with demand
Right-sizing
Right-sizing
• Selecting the cheapest instance available
while meeting performance requirements
• Looking at CPU, RAM, storage, and network
utilization to identify potential instances that
can be downsized
• Leveraging Amazon CloudWatch metrics and
setting up custom RAM metrics
Rule of thumb: Right size, then reserve.
(But if you’re in a pinch, reserve first.)
Use Spot Instances
• Price based on supply/demand
• You choose your maximum price/hour
• Your instance is started if the Spot price is lower
• Your instance is terminated if
the Spot price is higher, with 2 minutes notice
• But: You did plan for fault tolerance, didn’t you?
Spot Instance example
On-Demand:
$0.24
$0.028 (11.7%) $0.026 (10,8%)
$3.28
(1367%)
Spot Instance use cases
• Stateless Web/App server fleets
• Amazon EMR
• Continuous Integration (CI)
• High Performance Computing (HPC)
• Grid Computing
• Media Rendering/Transcoding
aws.amazon.com/ec2/spot
Spot Bid Advisor
Spot Instances recap
• Very dynamic pricing
• Opportunity to save 80-90% cost
• But there are risks
• Different prices per AZ
• Leverage Auto Scaling!
• One group with Spot Instances
• One group with On-Demand
• Get the best of both worlds
• Spot fleets – Manage thousands of
Spot Instance with one API call
“But my applications are
too small
for Auto Scaling!”
Amazon EC2 Container Service
• Easily manage Docker Containers
• Flexible Container placement
• Designed for use with other AWS services
• Extensible
• Performance at Scale
• Secure
10%
15%
7%
12%
20%
9%
Consolidate with Amazon ECS
App 1 App 2
App 3 App 4
App 5 App 6
6
12 34
5
Amazon ECS
Cluster
AWS Lambda
Amazon S3 Bucket Events
AWS Lambda
Original object Compressed object
1
2
3
“No server is easier to manage than no server”
Get rid of idle time with AWS Lambda
• Automatic scaling
• Automatic provisioning
• No need to manage infrastructure
• Just bring your code
• $0.20 per million requests, 1M free
• 100 ms payment granularity
• Never pay for idle
Less than 40% utilization?
Consider using AWS Lambda instead!
Optimizing Database Utilization
Database optimization through caching
DynamoDB Amazon RDS DynamoDB Amazon RDS
ElastiCache
Caching saves money
DynamoDB Reads
Saved 3k reads per second (>20k reads per second in total)
Synchronous writes
Sync/check in the app with after-write return values
DynamoDB
ElastiCache
write/update always
write/update always
Uncoupled writes/invalidation
Sync/Updates via Lambda (uncoupled)
DynamoDB
ElastiCache
write/update always
no update
Lambda
DynamoDB
Stream
update
Other tools & services for DynamoDB Optimization
Offload popular traffic to
Amazon S3 and/or Amazon CloudFront
Operational Goals
“Focus on what you do best,
let AWS do the rest.”
Leverage existing services
• Use Amazon RDS, DynamoDB,
ElastiCache for Redis or
Amazon Redshift
• Instead of running your own database
• Amazon Elasticsearch Service
• Instead of running your own cluster
• Amazon SQS
• Amazon Kinesis,
Amazon Kinesis Firehose, Amazon SNS, and more …
AWS has experts for each service
RDS
Amazon Redshift
Elasticsearch
Amazon Kinesis
SQS
DynamoDB
Pick the right tool for the job
Key/Value
Scalable
throughput
Low latency
Amazon Aurora
More complex
data/queries
Scalable
storage
Amazon
Redshift
Big (complex)
data
Higher
latency
ElastiCache
for Redis
Key/Value
In-Memory
(Very) low
latency
There is no one database to rule them all
MongoDB
Tracking
API
RTB
Engine
User&Stats
API
Tracking
API
RTB
Engine
DynamoDB
Decoupled
Amazon
Aurora
Amazon
Redshift
User&Stats
API
Bringing it all together
Recap
1. Use AWS TCO/cost/billing tools
2. Use Reserved Instances
3. Increase elasticity by avoiding idle instances (automation)
4. Use Spot Instances
5. Use right sized instances
6. Optimize database utilization
7. Pick the right tool for the job
8. Monitor, measure and improve.
Thank you!

More Related Content

Running Lean Architectures

  • 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Minoo Duraipandy, AWS Solution Architect (Repeat of ARC313 from re:Invent 2016) 11/30/2016 Running Lean Architectures How to Optimize for Cost Efficiency
  • 2. Original Speakers @ re:Invent 2016 Markus Ostertag, Head of Development, Team Internet AG Constantin Gonzalez, Principal Solutions Architect, AWS ARC313 Running Lean Architectures: How to Optimize for Cost Efficiency
  • 3. What you’ll get out of this session • Best practices on how to lower your AWS bill • A more scalable, robust, dynamic architecture • More time to innovate • Real-world customer examples • Easy to implement
  • 4. AWS pricing philosophy Ecosystem Global Footprint New Features New Services More AWS Usage More Infrastructure Lower Infrastructure Costs Reduced Prices More CustomersInfrastructure Innovation 57 price reductions since 2006Economies of Scale
  • 5. The Holy Grail of Cost Optimization “Pay for what you use.” “Pay as little as possible for what we use.” “Pay for what you need.”
  • 7. AWS simple monthly calculator
  • 11. Free Trusted Advisor Trial! • Free trial begins on 12/6/16 • Runs for 30 days • Full suite of checks and best practice recommendations available • For customers not already on business/enterprise support plans • No action required: Just log in and start using! https://console.aws.amazon.com/trustedadvisor
  • 13. Reserved Instances basics 1y RI Break even 3y RI Break even
  • 14. Reserved Instances – customer usage (large German software company)
  • 15. Use regional benefit Change existing Reserved Instances to scope “region” Capacity reservation decoupled from cost optimization
  • 16. Convertible Reserved Instances Use case: “(Very) Long running, but flexible”
  • 17. Architecture Goals “Avoid waste as much as possible.”
  • 18. Turn off unused instances • Developer, test, training instances • Use simple instance start and stop • Or tear down and build up all together using AWS CloudFormation • Instances are disposable!
  • 19. Customer example Monday Friday End of Vacation Season 35% saved
  • 20. Automate, automate, automate • AWS SDKs • AWS CLI • AWS CloudFormation • AWS OpsWorks • Netflix Janitor Monkey • Cloudlytics EC2 Scheduler • Auto Scaling
  • 22. AWS CloudFormation Example Launch Configuration "LaunchConfig": { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { … packages, sources, files, services … } } }, "Properties": { "ImageId" : "ami-149f7863", "InstanceType" : "m1.small", "SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ], "KeyName" : "MySSHKey", "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -vn", … your user data script … ]]}} } }
  • 23. AWS CloudFormation Example Auto Scaling Group Definition "WebServerGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "AvailabilityZones" : [ "us-east-1a", "us-east-1b", "us-east-1c", ], "LaunchConfigurationName" : { "Ref" : "LaunchConfig" }, "MinSize" : “3", "MaxSize" : “6", "DesiredCapacity" : “3", "LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ] } }
  • 25. Right-sizing Right-sizing • Selecting the cheapest instance available while meeting performance requirements • Looking at CPU, RAM, storage, and network utilization to identify potential instances that can be downsized • Leveraging Amazon CloudWatch metrics and setting up custom RAM metrics Rule of thumb: Right size, then reserve. (But if you’re in a pinch, reserve first.)
  • 26. Use Spot Instances • Price based on supply/demand • You choose your maximum price/hour • Your instance is started if the Spot price is lower • Your instance is terminated if the Spot price is higher, with 2 minutes notice • But: You did plan for fault tolerance, didn’t you?
  • 27. Spot Instance example On-Demand: $0.24 $0.028 (11.7%) $0.026 (10,8%) $3.28 (1367%)
  • 28. Spot Instance use cases • Stateless Web/App server fleets • Amazon EMR • Continuous Integration (CI) • High Performance Computing (HPC) • Grid Computing • Media Rendering/Transcoding aws.amazon.com/ec2/spot
  • 30. Spot Instances recap • Very dynamic pricing • Opportunity to save 80-90% cost • But there are risks • Different prices per AZ • Leverage Auto Scaling! • One group with Spot Instances • One group with On-Demand • Get the best of both worlds • Spot fleets – Manage thousands of Spot Instance with one API call
  • 31. “But my applications are too small for Auto Scaling!”
  • 32. Amazon EC2 Container Service • Easily manage Docker Containers • Flexible Container placement • Designed for use with other AWS services • Extensible • Performance at Scale • Secure
  • 33. 10% 15% 7% 12% 20% 9% Consolidate with Amazon ECS App 1 App 2 App 3 App 4 App 5 App 6 6 12 34 5 Amazon ECS Cluster
  • 34. AWS Lambda Amazon S3 Bucket Events AWS Lambda Original object Compressed object 1 2 3 “No server is easier to manage than no server”
  • 35. Get rid of idle time with AWS Lambda • Automatic scaling • Automatic provisioning • No need to manage infrastructure • Just bring your code • $0.20 per million requests, 1M free • 100 ms payment granularity • Never pay for idle Less than 40% utilization? Consider using AWS Lambda instead!
  • 37. Database optimization through caching DynamoDB Amazon RDS DynamoDB Amazon RDS ElastiCache
  • 38. Caching saves money DynamoDB Reads Saved 3k reads per second (>20k reads per second in total)
  • 39. Synchronous writes Sync/check in the app with after-write return values DynamoDB ElastiCache write/update always write/update always
  • 40. Uncoupled writes/invalidation Sync/Updates via Lambda (uncoupled) DynamoDB ElastiCache write/update always no update Lambda DynamoDB Stream update
  • 41. Other tools & services for DynamoDB Optimization
  • 42. Offload popular traffic to Amazon S3 and/or Amazon CloudFront
  • 43. Operational Goals “Focus on what you do best, let AWS do the rest.”
  • 44. Leverage existing services • Use Amazon RDS, DynamoDB, ElastiCache for Redis or Amazon Redshift • Instead of running your own database • Amazon Elasticsearch Service • Instead of running your own cluster • Amazon SQS • Amazon Kinesis, Amazon Kinesis Firehose, Amazon SNS, and more … AWS has experts for each service RDS Amazon Redshift Elasticsearch Amazon Kinesis SQS
  • 45. DynamoDB Pick the right tool for the job Key/Value Scalable throughput Low latency Amazon Aurora More complex data/queries Scalable storage Amazon Redshift Big (complex) data Higher latency ElastiCache for Redis Key/Value In-Memory (Very) low latency
  • 46. There is no one database to rule them all MongoDB Tracking API RTB Engine User&Stats API Tracking API RTB Engine DynamoDB Decoupled Amazon Aurora Amazon Redshift User&Stats API
  • 47. Bringing it all together
  • 48. Recap 1. Use AWS TCO/cost/billing tools 2. Use Reserved Instances 3. Increase elasticity by avoiding idle instances (automation) 4. Use Spot Instances 5. Use right sized instances 6. Optimize database utilization 7. Pick the right tool for the job 8. Monitor, measure and improve.