Running Lean and Mean: Designing Cost-efficient Architectures on AWS (ARC313) | AWS re:Invent 2013
- 1. Running Lean and Mean:
Designing Cost-Effective Architectures on AWS
Constantin Gonzalez, Solutions Architect, Amazon
Ralph Gootee, CTO and co-founder, PlanGrid.com
November 14, 2013
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
Friday, November 15, 13
- 2. What You’ll Get out of this Session
• A lower AWS bill
• A more scaleable, robust, dynamic architecture
• More time to innovate
• Real-world customer examples
• All in 7 easy to implement sections
Friday, November 15, 13
- 3. Cloud Computing Benefits
• Pay-as-you-go, no up-front investments
• Low on-going cost
• Flexible capacity
• Speed, agility & innovation
• Focus on your business
• Go global in Minutes
Friday, November 15, 13
- 4. Cloud Computing Benefits
• Pay-as-you-go, no up-front investments
• Low on-going cost
• Flexible capacity
• Speed, agility & innovation
• Focus on your business
• Go global in Minutes
Friday, November 15, 13
- 9. AWS CloudFormation: Load Balancer
"ElasticLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Metadata" : {"Comment" : "This is my load balancer!"},
"Properties" : {
"AvailabilityZones" : [ "us-east-1a", "us-east-1b", "us-east-1c",],
"LBCookieStickinessPolicy" : [ {
"PolicyName" : "CookieBasedPolicy",
"CookieExpirationPeriod" : "30"
} ],
"Listeners" : [ {
"LoadBalancerPort" : "80",
"InstancePort" : "80",
"Protocol" : "HTTP",
"PolicyNames" : [ "CookieBasedPolicy" ]
} ],
"HealthCheck" : {
"Target" : "HTTP:80/",
"HealthyThreshold" : "2",
"UnhealthyThreshold" : "5",
"Interval" : "10",
"Timeout" : "5"
} } }
Friday, November 15, 13
- 10. AWS CloudFormation: 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 …
]]}}
}
}
Friday, November 15, 13
- 11. AWS CloudFormation: Auto Scaling Group
}
"WebServerGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : [
"us-east-1a",
"us-east-1b",
"us-east-1c",
],
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
"MinSize" : "1",
"MaxSize" : "5",
"DesiredCapacity" : "2",
"LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]
}
Friday, November 15, 13
- 12. Auto Scaling Tips
• Scale up like a rocket
• Scale down like a feather
• Find the right instance type
• Leave headroom for peaks
• Bonus: Better fault-tolerance
• Bonus: Better scalability
Friday, November 15, 13
- 14. #2: Turn off Unused Instances
• Developer/test/training instances
• Use simple instance start/stop, or
• Tear down/build up altogether
• Instances are disposable
• Automate, automate, automate:
• AWS CloudFormation
• Weekend/off-hours scripts
• Use tags
Friday, November 15, 13
- 17. #3: Use Reserved Instances
3y RI
Break even
1y RI
Break even
Friday, November 15, 13
- 18. Reserved Instances Just Got More Flexible
• Can now be moved between AZs
• Can be moved between EC2-Classic
and EC2-VPC platforms
• Size can be modified within the same
instance family
Friday, November 15, 13
- 21. #4: Use Spot Instances
• Price based on supply/demand
• You choose your maximum price/hour
• Your instance is started if Spot Price is lower
• Your instance is terminated if Spot Price is higher
• But: You did plan for fault-tolerance,
didn’t you?
Friday, November 15, 13
- 22. #4: Use Spot Instances
$3.28
(1367%)
On-demand:
$0.24
$0.028 (11.7%)
Friday, November 15, 13
$0.026 (10,8%)
- 23. #4: Use Spot Instances
• 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
Friday, November 15, 13
- 24. Spot Instance Use Cases
• Batch processing
• Amazon Elastic MapReduce
• Web crawlers
• Development/Test
• Video/Image rendering
• HPC
• Monte-Carlo analysis
Friday, November 15, 13
- 25. AWS CloudFormation: Using Spot Instances
"LaunchConfig": {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
… packages, sources, files, services …
}
}
},
"SpotPrice": "0.59",
"Properties": {
"ImageId" : "ami-149f7863",
"InstanceType"
: "m1.small",
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
"KeyName"
: "MySSHKey",
"UserData"
: { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -vn",
… your user data script …
]]}}
}
}
Friday, November 15, 13
- 26. Customer Case Study: tadaa.net
• Photo sharing mobile app
• Built-in social network
• >3 Million users
• Moved from on-demand to Spot
• 57% reduction of Amazon EC2 bill
through Spot Instances
Friday, November 15, 13
- 37. You
Manage
Amazon
EC2
DownMme
Instability
Maintenance
Manpower
Friday, November 15, 13
- 38. AWS
Manages
Amazon
SQS
Redundant
Scaleable
314
Million
Requests
$157
Dollars
Friday, November 15, 13
- 42. #5: Leverage Amazon S3 Storage Classes
• Reduced Redundancy Storage Class
•
•
•
•
99.99% durability vs. 99.999999999%
Up to 20% savings
Great for everything that is easy to reproduce
Amazon SNS notification for lost objects available
• Amazon Glacier Storage Class
•
•
•
•
Same 99.999999999% durability as S3
3 to 5 hours restore time
Up to 89% savings
Great for archiving, long-term backups and old data
Friday, November 15, 13
- 44. #6 Optimize Amazon DynamoDB capacity units
• Read/write capacity units (CUs) determine most of
Amazon DynamoDB cost.
• By optimizing CUs, you can save a lot of money
• But:
• Need to provision enough capacity to not run into capacity errors
• Need to prepare for peaks
• Need to constantly monitor/adjust
Friday, November 15, 13
- 45. #6 Optimize Amazon DynamoDB capacity units
• Use caching to save read capacity units
• Local RAM caches at app server instances
• Check out Amazon ElastiCache
• Think of strategies for optimizing CU use
• Use multiple tables to support varied access patterns
• Understand access patterns for time series data
• Compress large attribute values
• Use Amazon SQS to buffer over-capacity
writes
Friday, November 15, 13
- 48. Customer Case Study: tadaa.net
• Huge growth after Instagram
• Heavy users of Amazon DynamoDB
Friday, November 15, 13
- 49. Amazon DynamoDB CUs @tadaa
Dynamic
DynamoDB:
20% saved
Caching/Optimization:
80% saved
Friday, November 15, 13
Cache
Flush
Growth +
new features
- 52. #7 Offload Your Architecture
• The more you can offload, the less infrastructure you
need to maintain, scale, and pay for.
• Three easy ways to offload:
• Use Amazon CloudFront
• Introduce Caching
• Leverage existing AWS services
Friday, November 15, 13
- 53. Offload Popular Traffic to Amazon S3, CloudFront
CDN'for'
Sta6c'
CDN'for'
Sta6c'&'
Content'
No'CDN'
Dynamic'
Content'
Friday, November 15, 13
Server'
Load'
Response'Time'
Server'
Load'
Response'Time'
Server'Load'
Response'Time'
Offload'
Scale''
Down'
- 58. Leverage Existing Services
• Amazon RDS, Amazon DynamoDB or ElastiCache for
Redis, Amazon Redshift
• instead of running your own database
• Amazon CloudSearch
• instead of running your own search engine
• Amazon Elastic Transcoder
• Amazon Elastic MapReduce
• Amazon SQS, Amazon SNS,
Amazon Simple WorkflowService, Amazon SES
Document)
Server)
Simple, more reliable, lower cost
Friday, November 15, 13
)
Search)
Server)
)
Results
- 63. Let’s Recap
1. Use Auto Scaling
2. Turn off unused instances
3. Use Reserved Instances
4. Use Spot Instances
5. Leverage Amazon S3 storage classes
6. Optimize Amazon DynamoDB capacity units
7. Offload your architecture
Friday, November 15, 13
- 64. Startup
Spotlight
Sessions
with
Dr.
Werner
Vogels
Thurs.
Nov
14,
Marcello
Room
4406
• SPOT 203 - Fireside Chats – Startup Founders, 1:30-2:30pm
• Eliot Horowitz, CTO of MongoDB
• Jeff Lawson, CEO of Twilio
• Valentino Volonghi, Chief Architect of AdRoll
• SPOT 204 - Fireside Chats – Startup Influencers, 3:00-4:00pm
• Albert Wegner, Managing Partner at Union Square Ventures
• David Cohen, Founder and CEO of TechStars
• SPOT 101 - Startup Launches, 4:15-5:15pm
• 5 companies powered by AWS launching at AWS re:Invent 2013
Friday, November 15, 13
- 65. Please give us your feedback on this
presentation
ARC313
As a thank you, we will select prize
winners daily for completed surveys!
Friday, November 15, 13
Thank You