Optimizing for Cost in the Cloud             Jinesh Varia               @jinman         Technology Evangelist
Multiple dimensions of optimizations                                  Cost                                  Performance   ...
Optimizing for Cost
When you turn off your cloud resources,     you actually stop paying for them
Continuous optimization in your architecture results       in recurring savings in your next month’s bill
Elasticity is one of the fundamentalproperties of the cloud that drives many of its                            economic be...
Optimizing for Cost…  #1 Use only what you need (use Auto Scaling Service, modify–db)
Turn off what you don’t need (automatically)
Daily CPU Load         14         12         10         8  Load         6                           25% Savings         4 ...
www.MyWebSite.com         (dynamic data)                       Amazon Route 53                                            ...
Web Servers           50% Savings                1   5    9   13   17   21   25 29   33   37   41   45   49               ...
Auto scaling : Types of ScalingScaling by Schedule• Use Scheduled Actions in Auto Scaling Service    • Date    • Time    •...
Auto scaling Best PracticesUse Auto Scaling TagsUse Auto scaling Alarms and Email NotificationsScale up and down symmetric...
Example:Scale up by 10%if CPU utilization is greater than 60%for 5 minutes,Scale down by 10%if CPU utilization is less tha...
Instances   Agg. CPU
RDS DB Servers                       75% Savings                 1   3   5   7   9   11 13 15 17 19 21 23 25 27 29        ...
End of the month processingExpand the cluster at the end of the month• Expand/Shrink feature in Amazon Elastic MapReduceVe...
Tip: Use “Reminder scripts”   Disassociate your unused EIPs   Delete unassociated EBS volumes   Delete older EBS snapsh...
AWS Support – Trusted Advisor –  Your personal cloud assistant
Tip – Instance Optimizer             Free Memory              Free CPU         PUT                       2 weeks          ...
Optimizing for Cost…  #1 Use only what you need (use Auto Scaling Service, modify–db)        #2 Invest time in Reserved Pr...
Save more when you reserve   On-demand           Reserved    Instances          Instances                          Heavy  ...
The Total Cost Of (Non) Ownership in the               Cloud Whitepaper (New!)         Whitepaper: http://bit.ly/aws-tco-w...
Web Application Usage Patterns       Steady State             Spiky Predictable    Uncertain unpredictable       Usage Pat...
www.MyWebSite.com                                  (dynamic data)     Example: TCO of a                          Amazon Ro...
$14.000                      m2.xlarge running Linux in US-East Region          $12.000                      over 3 Year p...
Spiky Predictable Usage Pattern                                        12Traffic measured in Servers/Instances            ...
TCO of Spiky Predictable Web Application   TCO                                   Web Application - Spiky Usage Pattern    ...
RecommendationsSteady State Usage Pattern• For 100% utilization    • 3-Year Heavy RI (for maximum savings over on-demand)S...
Optimizing for Cost…  #1 Use only what you need (use Auto Scaling Service, modify–db)        #2 Invest time in Reserved Pr...
Optimize by using Spot Instances  On-demand                   Reserved                     Spot   Instances               ...
What are Spot Instances?             Sold at                                               Sold at               50%      ...
What is the tradeoff?            Unused                                           Unused                      Unused      ...
Spot Use casesUse Case                  Types of ApplicationsBatch Processing          Generic background processing (scal...
Save more money by using Spot InstancesReserved Hourly Price > Spot Price < On-Demand Price
Spot: Example Customers                57%                           50%63%               50%                          56%...
Typical Spot Bidding Strategies                                          Bid Distribution (for last 3 months)             ...
1. Bid Near the Reserved Hourly Price$$$$$$$$$$$$$$$$$$ $$$        $   $       $   $                                      ...
2. Bid above the Spot Price History                                      50% Savings over                                 ...
3. Bid near the On-Demand Price                                  50% Savings over                                  On-Demand
4. Bid above the On-Demand Price                                   57% Savings over                                   On-D...
Managing Interruption
Amazon EMR (Hadoop): Run Task Nodes on Spot                                                            Amazon S3          ...
Amazon EMR: Reducing Cost with SpotScenario #1                    #1: Cost without Spot   Job Flow         4 instances *14...
Made for each other: MapReduce + Spot                           Use Case: Web crawling/Search                           us...
Video Transcoding Application Example                     Amazon S3                                              Amazon S3...
Use of Amazon SQS in Spot ArchitecturesVisibilityTimeOut                     Amazon EC2                    Spot Instance
Optimizing Video Transcoding Workloads   Free Offering                          Premium Offering    • Optimize for reducin...
Persistent Requests
Architecting for Spot Instances : Best PracticesManage interruption• Split up your work into small increments• Checkpointi...
Optimizing for Cost…  #1 Use only what you need (use Auto Scaling Service, modify–db)        #2 Invest time in Reserved Pr...
Optimize by converting ancillary instances into                                       services                       Monit...
Elastic Load BalancingSoftware LB on EC2                   Elastic Load BalancingPros                                 Pros...
$0.025 per hour                   DNS   Elastic Load                                                      Web Servers     ...
Application ServicesSoftware on EC2                  SNS, SQS, SES, SWFPros                             Pros   Custom feat...
Consumers                          Producer     SQS queue$0.01 per10,000 Requests($0.000001 per Request)  $0.08     per ho...
Optimizing for Cost…  #1 Use only what you need (use Auto Scaling Service, modify–db)        #2 Invest time in Reserved Pr...
caching             Optimize for performance and costby page caching and edge-caching static content
When am I charged?                                                    Paris                                               ...
When content is popular…                                                    Paris                                         ...
Architectural RecommendationsUse Amazon S3 + CloudFront as it will reduce the cost as wellas reduce latency for static dat...
Number of ways to further save with AWS…  #1 Use only what you need (use Auto Scaling Service, modify–db)        #2 Invest...
Thank you!jvaria@amazon.com  Twitter: @jinman
http://aws.amazon.com
Optimizing for Costs in the Cloud
Optimizing for Costs in the Cloud
Upcoming SlideShare
Loading in …5
×

Optimizing for Costs in the Cloud

1,105 views
1,008 views

Published on

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,105
On SlideShare
0
From Embeds
0
Number of Embeds
273
Actions
Shares
0
Downloads
33
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Optimizing for Costs in the Cloud

  1. 1. Optimizing for Cost in the Cloud Jinesh Varia @jinman Technology Evangelist
  2. 2. Multiple dimensions of optimizations Cost Performance Response time Time to market High-availability Scalability Security Manageability …….
  3. 3. Optimizing for Cost
  4. 4. When you turn off your cloud resources, you actually stop paying for them
  5. 5. Continuous optimization in your architecture results in recurring savings in your next month’s bill
  6. 6. Elasticity is one of the fundamentalproperties of the cloud that drives many of its economic benefits
  7. 7. Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db)
  8. 8. Turn off what you don’t need (automatically)
  9. 9. Daily CPU Load 14 12 10 8 Load 6 25% Savings 4 2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 HourOptimize by the time of day
  10. 10. www.MyWebSite.com (dynamic data) Amazon Route 53 media.MyWebSite.com (DNS) (static data) Elastic Load Balancer Amazon Auto Scaling group : Web Tier CloudFront Amazon EC2 Auto Scaling group : App Tier Amazon RDS Amazon Amazon S3Availability Zone #1 RDS Availability Zone #2
  11. 11. Web Servers 50% Savings 1 5 9 13 17 21 25 29 33 37 41 45 49 WeekOptimize during a year
  12. 12. Auto scaling : Types of ScalingScaling by Schedule• Use Scheduled Actions in Auto Scaling Service • Date • Time • Min and Max of Auto Scaling Group Size• You can create up to 125 actions, scheduled up to 31 days into the future, for each of your auto scaling groups. This gives you the ability to scale up to four times a day for a month.Scaling by Policy• Scaling up Policy - Double the group size• Scaling down Policy - Decrement by 1
  13. 13. Auto scaling Best PracticesUse Auto Scaling TagsUse Auto scaling Alarms and Email NotificationsScale up and down symmetricallyScale up quickly and scaling down slowlyAuto Scaling across Availability ZonesLeverage Suspend and Resume Processes
  14. 14. Example:Scale up by 10%if CPU utilization is greater than 60%for 5 minutes,Scale down by 10%if CPU utilization is less than 30%for 20 minutes.
  15. 15. Instances Agg. CPU
  16. 16. RDS DB Servers 75% Savings 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 Days of the MonthOptimize during a month
  17. 17. End of the month processingExpand the cluster at the end of the month• Expand/Shrink feature in Amazon Elastic MapReduceVertically Scale up at the end of the month• Modify-DB-Instance (in Amazon RDS) (or a New RDS DB Instance )• CloudFormation Script (in Amazon EC2)
  18. 18. Tip: Use “Reminder scripts” Disassociate your unused EIPs Delete unassociated EBS volumes Delete older EBS snapshots Leverage S3 Object Expiration
  19. 19. AWS Support – Trusted Advisor – Your personal cloud assistant
  20. 20. Tip – Instance Optimizer Free Memory Free CPU PUT 2 weeks Free HDD At 1-min intervals Alarm Amazon CloudWatchInstance Custom Metrics “You could save a bunch of money by switching to a small instance, Click on CloudFormation Script to Save” $$$ inSavings
  21. 21. Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS)
  22. 22. Save more when you reserve On-demand Reserved Instances Instances Heavy Utilization RI• Pay as you go • One time low upfront fee + 1-year and 3- Medium Pay as you go year terms Utilization RI• Starts from • $23 for 1 year term and Light $0.02/Hour Utilization RI $0.01/Hour
  23. 23. The Total Cost Of (Non) Ownership in the Cloud Whitepaper (New!) Whitepaper: http://bit.ly/aws-tco-webapps
  24. 24. Web Application Usage Patterns Steady State Spiky Predictable Uncertain unpredictable Usage Pattern Usage Pattern Usage Pattern(Example: Corporate Website) (Example: Marketing (Example: Social game or Promotions Website) Mobile Website)
  25. 25. www.MyWebSite.com (dynamic data) Example: TCO of a Amazon Route 53 media.MyWebSite.com (DNS)3-tier Web Application Elastic Load (static data) Balancer Amazon Auto Scaling group : Web Tier CloudFront Amazon EC2 Auto Scaling group : App Tier Amazon RDS Amazon Amazon S3 Availability Zone #1 RDS Availability Zone #2
  26. 26. $14.000 m2.xlarge running Linux in US-East Region $12.000 over 3 Year period Break-even $10.000 point $8.000 Cost Heavy Utilization $6.000 Medium Utilization Light Utilization $4.000 On-Demand $2.000 $- UtilizationUtilization Sweet Spot Feature Savings over On-Demand<10% On-Demand No Upfront Commitment10% - 40% Light Utilization RI Ideal for Disaster Recovery Up to 56% (3-Year)40% - 75% Medium Utilization RI Standard Reserved Capacity Up to 66% (3-Year)>75% Heavy Utilization RI Lowest Total Cost Up to 71% (3-Year) Ideal for Baseline Servers
  27. 27. Spiky Predictable Usage Pattern 12Traffic measured in Servers/Instances 10 8 6 Traffic Pattern EC2 Reserved 4 EC2 On-Demand Physical servers (on-premises) 2 0 0 5 10 15 20 25 30 35 Months
  28. 28. TCO of Spiky Predictable Web Application TCO Web Application - Spiky Usage Pattern On-Premises AWS Option 1 AWS Option 2 AWS Option 3 Amortized monthly costs All Reserved Mix of On-Demand All On-Demand Option over 3 years and ReservedOption 1: All Reserved Compute/Server Costs Server Hardware $510 $0 $0 $0 Network Hardware $103 $0 $0 $0Option 2: Mix of On-Demand and Reserved Hardware MaintenanceRecommended Option (Most Cost- $78 $0 $0 $0effective)Power and Cooling $286 $0 $0 $0 Data Center Space $240 $0 $0 $0 Personnel $2,000 $0 $0 $0Option 3: AWS Instances All On-Demand $0 $992 $881 $1,940Commitment-free and Risk-free Option Total - Per Month $3,220 $992 $881 $1,940 Total - 3 Years $115,920 $35,717 $31,731 $69,854 Savings over On-premises 69% 72% 40% Option
  29. 29. RecommendationsSteady State Usage Pattern• For 100% utilization • 3-Year Heavy RI (for maximum savings over on-demand)Spiky Predictable Usage Pattern• Baseline • 3-Year Heavy RI (for maximum savings over on-demand) • 1-Year Light RI (for lowest upfront commitment) + savings over on-demand• Peak: On-DemandUncertain and unpredictable Usage Pattern• Start out small with On-Demand Instances (risk-free and commitment- free)• Switch to some combination of Reserved and On-Demand, if application is successful• If not successful, you walk away having spent a fraction of what you would pay to buy your own technology infrastructure
  30. 30. Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS) #3 Architect for Spot Instances (bidding strategies)
  31. 31. Optimize by using Spot Instances On-demand Reserved Spot Instances Instances Instances• Pay as you go • One time low • Requested Bid upfront fee + Price and Pay Pay as you go as you go• Starts from • $23 for 1 year • $0.005/Hour $0.02/Hour term and as of today at $0.01/Hour 9 AM 1-year and 3- year terms Heavy Medium Light Utilization Utilization RI Utilization RI RI
  32. 32. What are Spot Instances? Sold at Sold at 50% Unused 54% Unused Discount! Discount! Sold at Sold at 56% Unused 59% Unused Discount! Discount! Sold at Sold at 66% Unused 63% UnusedDiscount! Discount! Availability Zone Availability Zone Region
  33. 33. What is the tradeoff? Unused Unused Unused Reclaimed Unused UnusedReclaimed Unused Availability Zone Availability Zone Region
  34. 34. Spot Use casesUse Case Types of ApplicationsBatch Processing Generic background processing (scale out computing)Hadoop Hadoop/MapReduce processing type jobs (e.g. Search, Big Data, etc.)Scientific Computing Scientific trials/simulations/analysis in chemistry, physics, and biologyVideo and Image Transform videos into specific formatsProcessing/RenderingTesting Provide testing of software, web sites, etcWeb/Data Crawling Analyzing data and processing itFinancial Hedgefund analytics, energy trading, etcHPC Utilize HPC servers to do embarrassingly parallel jobsCheap Compute Backend servers for Facebook games
  35. 35. Save more money by using Spot InstancesReserved Hourly Price > Spot Price < On-Demand Price
  36. 36. Spot: Example Customers 57% 50%63% 50% 56%50% 66% 50%
  37. 37. Typical Spot Bidding Strategies Bid Distribution (for last 3 months) 20% 1. Bid near the 18% Reserved Hourly PricePercentage of the Distribution 16% 14% 2. Bid above the 12% Spot Price 10% History 8% 3. Bid near On- 6% Demand Price 4% 2% 4. Bid above the 0% On-Demand Price Bid Price as Percentage of the On-Demand Price
  38. 38. 1. Bid Near the Reserved Hourly Price$$$$$$$$$$$$$$$$$$ $$$ $ $ $ $ 66% Savings over On-Demand
  39. 39. 2. Bid above the Spot Price History 50% Savings over On-Demand
  40. 40. 3. Bid near the On-Demand Price 50% Savings over On-Demand
  41. 41. 4. Bid above the On-Demand Price 57% Savings over On-Demand
  42. 42. Managing Interruption
  43. 43. Amazon EMR (Hadoop): Run Task Nodes on Spot Amazon S3 Upload large datasets or log Amazon S3 Data files directly Input Source Data Outpu tData Task Amazon Elastic Node MapReduce Amazon DynamoDB Mapper Code/ Reducer Name Task Service Metadata Scripts HiveQL Node Node Pig Latin Cascading Runs multiple JobFlow Steps Core HiveQL Node Pig Latin Query Core Node HDFS BI Apps Amazon Elastic MapReduce JDBC/ODB C Hadoop Cluster
  44. 44. Amazon EMR: Reducing Cost with SpotScenario #1 #1: Cost without Spot Job Flow 4 instances *14 hrs * $0.45 = $25.20 Duration: 14 Hours #2: Cost with Spot 4 instances *7 hrs * $0.45 = $12.60 + 5 instances * 7 hrs * $0.225 = $7.875Scenario #2 Total = $20.475 Job Flow Time Savings: 50% Duration: Cost Savings: ~19% 7 Hours
  45. 45. Made for each other: MapReduce + Spot Use Case: Web crawling/Search using Hadoop type clusters. Use Reserved Instances for their DB workloads and Spot instances for their indexing clusters. Launch 100’s of instances. Bidding Strategy: Bid a little above the On-Demand price to prevent interruption. Interruption Strategy: Restart the cluster if interrupted 66% Savings over On-Demand
  46. 46. Video Transcoding Application Example Amazon S3 Amazon S3 Amazon Elastic Compute Cloud Input Output Bucket BucketAmazon EC2 Amazon SQS Amazon SQS Job Completed Reports Job Website Input Output Website Queue Queue Amazon EC2 (Job Manager) On-demand + Spot Amazon Amazon DynamoDB CloudWatch Amazon DynamoDB Amazon EC2 Intranet
  47. 47. Use of Amazon SQS in Spot ArchitecturesVisibilityTimeOut Amazon EC2 Spot Instance
  48. 48. Optimizing Video Transcoding Workloads Free Offering Premium Offering • Optimize for reducing cost  Optimized for Faster response times • Acceptable Delay Limits  No DelaysImplementation Implementation • Set Persistent Requests  Invest in RIs • Use on-demand Instances, if  Use on-demand for Elasticity delay Maximum Bid Price Maximum Bid Price < On-demand Rate >= On-demand Rate Get your set reduced price for Get Instant Capacity for higher price your workload
  49. 49. Persistent Requests
  50. 50. Architecting for Spot Instances : Best PracticesManage interruption• Split up your work into small increments• Checkpointing: Save your work frequently and periodicallyTest Your ApplicationTrack when Spot Instances Start and StopSpot Requests• Use Persistent Requests for continuous tasks• Choose maximum price for your requests
  51. 51. Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS) #3 Architect for Spot Instances (bidding strategies)#4 Leverage Application Services (ELB, SNS, SQS, SWF, SES)
  52. 52. Optimize by converting ancillary instances into services Monitoring: CloudWatch Notifications: SNS Queuing: SQS SendMail: SES Load Balancing: ELB Workflow: SWF Search: CloudSearch
  53. 53. Elastic Load BalancingSoftware LB on EC2 Elastic Load BalancingPros Pros Application-tier load Elastic and Fault-tolerant balancer Auto scaling Monitoring includedCons SPOF Cons Elasticity has to be For Internet-facing traffic implemented manually only Not as cost-effective
  54. 54. $0.025 per hour DNS Elastic Load Web Servers Balancer Availability Zone$0.08 per hour(small instance) EC2 instance DNS + software LB Web Servers Availability Zone
  55. 55. Application ServicesSoftware on EC2 SNS, SQS, SES, SWFPros Pros Custom features Pay as you go ScalabilityCons Availability Requires an instance High performance SPOF Limited to one AZ DIY administration
  56. 56. Consumers Producer SQS queue$0.01 per10,000 Requests($0.000001 per Request) $0.08 per hour (small instance) Producer EC2 instance Consumers + software queue
  57. 57. Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS) #3 Architect for Spot Instances (bidding strategies)#4 Leverage Application Services (ELB, SNS, SQS, SWF, SES) #5 Implement Caching (ElastiCache, CloudFront)
  58. 58. caching Optimize for performance and costby page caching and edge-caching static content
  59. 59. When am I charged? Paris Client Edge Location Amazon Simple Storage Service (S3) Client Singapore Amazon Elastic Compute Cloud (EC2) Edge Location London Edge Location Client
  60. 60. When content is popular… Paris Client Edge Location Amazon Simple Storage Service (S3) Client Singapore Amazon Elastic Compute Cloud (EC2) Edge Location London Edge Location Client
  61. 61. Architectural RecommendationsUse Amazon S3 + CloudFront as it will reduce the cost as wellas reduce latency for static data• Depends on cache-hit ratioFor Video Streaming, use CloudFront as there is no need of aseparate streaming server running Adobe FMSUse managed caching service (Amazon ElastiCache)
  62. 62. Number of ways to further save with AWS… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS) #3 Architect for Spot Instances (bidding strategies)#4 Leverage Application Services (ELB SNS, SQS, SWF, SES) #5 Implement Caching (ElastiCache, CloudFront)
  63. 63. Thank you!jvaria@amazon.com Twitter: @jinman
  64. 64. http://aws.amazon.com

×