AWS for Start-ups - Cost Optimisation with AWS

1,276 views

Published on

A key step in the journey through the AWS Cloud - realise cost aware architectures, use elasticity to gain real and measurable benefit. Do more, use less.

By Jonathon Southam, Start-ups UK

Published in: Technology

AWS for Start-ups - Cost Optimisation with AWS

  1. 1. Cost optimisation with AWS Jonathon Southam – Startups UK jsoutham@amazon.co.uk
  2. 2. Cost Optimization A key step in the cloud journey Realize cost aware architecturesUse elasticity to gain real and measurable benefit Do more, use less
  3. 3. AgendaFundamentals of AWS cost optimisationCost optimisation in 5 stepsWhere to go next
  4. 4. Fundamentals of cost optimization
  5. 5. Why optimize?
  6. 6. Why optimize? UtilityCompute and Storageare a utility so ‘turningoff’ should be natural
  7. 7. Why optimize? Utility EfficiencyCompute and Storage Efficiency allowsare a utility so ‘turning more to be doneoff’ should be natural within a given budget
  8. 8. Why optimize? Utility Efficiency ArchitectureCompute and Storage Efficiency allows Cost awareness drivesare a utility so ‘turning more to be done adoption of 21st centuryoff’ should be natural within a given budget architectures
  9. 9. Turn off the lightsWhen you stop EC2 resources you stop paying for them
  10. 10. Be elastic Support workloads with the rightamount of horsepower to get the job done
  11. 11. Continually optimizeDrive recurring and improving savings through cost aware architectures
  12. 12. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  13. 13. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  14. 14. Server Load 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 Hour of day
  15. 15. Server Load Capacity of 1 Server 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 Hour of day
  16. 16. Traditional capacity requiredServer Load Capacity of 1 Server 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 Hour of day
  17. 17. Traditional capacity requiredServer Load Capacity of 1 Server 1 Server for 8 hours 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 Hour of day
  18. 18. Traditional capacity requiredServer Load Capacity of 1 Server 1 Server for 8 hours 1 Server for 8 hours 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 Hour of day
  19. 19. Traditional capacity required 1 Server for 8 hoursServer Load Capacity of 1 Server 1 Server for 8 hours 1 Server for 8 hours 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 Hour of day
  20. 20. Traditional capacity required 1 Server for 8 hoursServer Load Capacity of 1 Server 1 Server for 8 hours 1 Server for 8 hours 1 Server for 8 hours 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 Hour of day
  21. 21. Traditional capacity requiredServer Load Capacity of 1 Server 1/3rd Saving 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 Hour of day
  22. 22. Elastic Capacity2 am
  23. 23. Elastic Capacity8 am
  24. 24. Elastic Capacity12 am
  25. 25. Elastic Capacity4 pm
  26. 26. Elastic Capacity10 pm
  27. 27. Time: +00h <10 coresElastic Capacity
  28. 28. Time: +24h >1500 coresElastic Capacity
  29. 29. Time: +72h <10 coresElastic Capacity
  30. 30. Time: +120h >600 coresElastic Capacity
  31. 31. Auto-scaling policies Manually By Schedule Send an API call or use CLI to Scale up/down based on date launch/terminate instances – and time Only need to specify capacity change (+/-) By Policy Auto-Rebalance Scale in response to changing Instances are automatically conditions, based on user launched/terminated to configured real-time ensure the application is monitoring and alerts balanced across multiple Azs
  32. 32. Auto-scaling policies Scaling base on Policy Scaling by ScheduleScale up and down base on metrics Scheduled Actions to meet known demandScaling Up policy - Double the group size if avg cpu > 80% Scheduled up to 31 days into the futureScaling Down policy - Decrement by Recurring scheduled scaling activities 10% if avg cpu < 30%
  33. 33. https://reinvent.awsevents.com/
  34. 34. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  35. 35. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  36. 36. Instance types
  37. 37. Instance types Start Choose instance that meets your basic requirements bestMatch memory & virtual cores
  38. 38. Instance types Start Tune Choose instance that Change instance size up meets your basic or down based upon requirements best monitoringMatch memory & virtual Use trusted advisor to cores assess
  39. 39. Instance types Start Tune Spread Choose instance that Change instance size up Run instances across meets your basic or down based upon multiple availability requirements best monitoring zonesMatch memory & virtual Use trusted advisor to Smaller sizes equals cores assess greater granularity
  40. 40. Know your usage Free Memory Free CPU Free HDD PUT 2 weeks … Custom Metrics … Amazon Instance At 1-min intervals Alarm CloudWatch
  41. 41. Choose your metric optimize for the metric
  42. 42. Choose your metric optimize for the metric Cost per unit of work per instance(size) Workload A Workload B Workload COptimal on 4x Optimal on 10x Optimal on 2x m1.xlarge m1.medium m3.xxlarge
  43. 43. Choose your metric optimize for the metric Cost per unit of work per instance(size)100 concurrent jobs on 10 x m1.large @ $0.24 / hr = $ 0.024 / job vs300 concurrent jobs on 10 x m3.xlarge @ $0.50 / hr = $ 0.016 / job
  44. 44. Choose your metric optimize for the metric Think workload densityDon’t focus on instance hourly rate per se
  45. 45. Master Accountaws.invoices@mycompany.com
  46. 46. Master Account aws.invoices@mycompany.comconsolidated billing information Division B admin@divisionB.com IAM User2 Dev2 Admin2
  47. 47. Master Account aws.invoices@mycompany.comconsolidated billing information Tags: (key- value) Division B e.g Own=Div Proj=R admin@divisionB.com IAM User2 Dev2 Admin2 Tags: Tags: Tags: Own=Div Own=Div Own=Div Proj=P Proj=Q Proj=R
  48. 48. Master Account aws.invoices@mycompany.com consolidated billing information Operating Co. A Division B Business Unit C admin@opcoa.com admin@divisionB.com admin@busUnitC.com User1 User2 User3 IAM IAM IAM Dev1 Dev2 Dev3 Admin1 Admin2 Admin3Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags:Own=OpCo Own=OpCo Own=OpCo Own=Div Own=Div Own=Div Own=BusC Own=BusC Own=BusCProj=A Proj=B Proj=C Proj=P Proj=Q Proj=R Proj=X Proj=Y Proj=Z
  49. 49. Master Account aws.invoices@mycompany.com consolidated billing information Operating Co. A Division B Business Unit C admin@opcoa.com admin@divisionB.com admin@busUnitC.com User1 User2 User3 IAM IAM IAM Dev1 Dev2 Dev3 Admin1 Admin2 Admin3Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags:Own=OpCo Own=OpCo Own=OpCo Own=Div Own=Div Own=Div Own=BusC Own=BusC Own=BusCProj=A Proj=B Proj=C Proj=P Proj=Q Proj=R Proj=X Proj=Y Proj=Z
  50. 50. Programmatic billing access Master Account aws.invoices@mycompany.com S3 CSV consolidated billing information Operating Co. A Division B Business Unit C admin@opcoa.com admin@divisionB.com admin@busUnitC.com User1 User2 User3 IAM IAM IAM Dev1 Dev2 Dev3 Admin1 Admin2 Admin3Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags:Own=OpCo Own=OpCo Own=OpCo Own=Div Own=Div Own=Div Own=BusC Own=BusC Own=BusCProj=A Proj=B Proj=C Proj=P Proj=Q Proj=R Proj=X Proj=Y Proj=Z
  51. 51. Programmatic billing access Master Account aws.invoices@mycompany.com S3 CSV consolidated billing information Operating Co. A Division B Business Unit C admin@opcoa.com admin@divisionB.com admin@busUnitC.com User1 User2 User3 IAM IAM IAM Dev1 Dev2 Dev3 Admin1 Admin2 Admin3Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags: Tags:Own=OpCo Own=OpCo Own=OpCo Own=Div Own=Div Own=Div Own=BusC Own=BusC Own=BusCProj=A Proj=B Proj=C Proj=P Proj=Q Proj=R Proj=X Proj=Y Proj=Z
  52. 52. Basic Offering 24x7x365 ✓Developer Forum Access ✓ Documentation ✓Business Access to support Phone, Chat, EmailEnterprise Named Contacts 5 Fastest Response Time 1 Hour Architecture Support Use Case Guidance Best Practice ✓ Diagnostics Tools ✓ Direct Routing ✓ 3rd Party Software ✓ Trusted Advisor ✓
  53. 53. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  54. 54. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  55. 55. Reserved instances On-demand instances Unix/Linux instances start at $0.02/hour Pay as you go for compute power Low cost and flexibility Pay only for what you use, no up-front commitments or long-term contracts Use Cases: Applications with short term, spiky, or unpredictable workloads; Application development or testing
  56. 56. Reserved instances On-demand instances Reserved instances Unix/Linux instances start at 1- or 3-year terms $0.02/hour Pay low up-front fee, receive significant hourly Pay as you go for compute power discount Low cost and flexibility Low Cost / Predictability Pay only for what you use, no up-front Helps ensure compute capacity is available commitments or long-term contracts when needed Use Cases: Use Cases: Applications with short term, spiky, or unpredictable workloads; Applications with steady state or predictable usage Application development or testing Applications that require reserved capacity, including disaster recovery
  57. 57. Reserved instances Heavy utilization RI > 80% utilization Lower costs up to 58% On-demand instances Reserved instances Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline Unix/Linux instances start at 1- or 3-year terms $0.02/hour Pay low up-front fee, receive significant hourly Pay as you go for compute power discount Low cost and flexibility Low Cost / Predictability Pay only for what you use, no up-front Helps ensure compute capacity is available commitments or long-term contracts when needed Use Cases: Use Cases: Applications with short term, spiky, or unpredictable workloads; Applications with steady state or predictable usage Application development or testing Applications that require reserved capacity, including disaster recovery
  58. 58. Reserved instances Heavy utilization RI > 80% utilization Lower costs up to 58% On-demand instances Reserved instances Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline Unix/Linux instances start at 1- or 3-year terms $0.02/hour Pay low up-front fee, receive significant hourly Medium utilization RI Pay as you go for compute power discount Low cost and flexibility Low Cost / Predictability 41-79% utilization Lower costs up to 49% Pay only for what you use, no up-front Helps ensure compute capacity is available Use Cases: Web applications, many heavy commitments or long-term contracts when needed processing tasks, running much of the time Use Cases: Use Cases: Applications with short term, spiky, or unpredictable workloads; Applications with steady state or predictable usage Application development or testing Applications that require reserved capacity, including disaster recovery
  59. 59. Reserved instances Heavy utilization RI > 80% utilization Lower costs up to 58% On-demand instances Reserved instances Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline Unix/Linux instances start at 1- or 3-year terms $0.02/hour Pay low up-front fee, receive significant hourly Medium utilization RI Pay as you go for compute power discount Low cost and flexibility Low Cost / Predictability 41-79% utilization Lower costs up to 49% Pay only for what you use, no up-front Helps ensure compute capacity is available Use Cases: Web applications, many heavy commitments or long-term contracts when needed processing tasks, running much of the time Use Cases: Use Cases: Applications with short term, spiky, or Light utilization RI unpredictable workloads; Applications with steady state or predictable usage Application development or testing 15-40% utilization Applications that require reserved capacity, Lower costs up to 34% including disaster recovery Use Cases: Disaster Recovery, Weekly / Monthly reporting, Elastic Map Reduce
  60. 60. Best RI for Utilisation $18,000 $16,000 $14,000 $12,000 $10,000 Heavy Medium $8,000 Light $6,000 O-Demand $4,000 $2,000 $-
  61. 61. Best RI for Utilisation $18,000 $16,000 $14,000 $12,000 $10,000 Heavy Medium $8,000 Light $6,000 O-Demand $4,000 $2,000 $-
  62. 62. Optimizing costs with RIs 14 12 10 On Demand 8 Light Utilization RI 6 Medium Utilization RI Heavy utilization RI 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
  63. 63. https://reinvent.awsevents.com/
  64. 64. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  65. 65. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  66. 66. Spot instances On-demand instances Reserved instances Unix/Linux instances start at 1- or 3-year terms $0.02/hour Pay low up-front fee, receive significant hourly Pay as you go for compute power discount Low cost and flexibility Low Cost / Predictability Pay only for what you use, no up-front Helps ensure compute capacity is available commitments or long-term contracts when needed Use Cases: Use Cases: Applications with short term, spiky, or unpredictable workloads; Applications with steady state or predictable usage Application development or testing Applications that require reserved capacity, including disaster recovery
  67. 67. Spot instances On-demand instances Reserved instances Spot instances Unix/Linux instances start at 1- or 3-year terms Bid on unused EC2 capacity $0.02/hour Pay low up-front fee, receive significant hourly Spot Price based on supply/demand, Pay as you go for compute power discount determined automatically Low cost and flexibility Low Cost / Predictability Cost / Large Scale, dynamic workload handling Pay only for what you use, no up-front Helps ensure compute capacity is available commitments or long-term contracts when needed Use Cases: Use Cases: Use Cases: Applications with flexible start and end times Applications with short term, spiky, or unpredictable workloads; Applications with steady state or predictable Applications only feasible at very low compute usage prices Application development or testing Applications that require reserved capacity, including disaster recovery
  68. 68. Achieving economies of scale 100% Time
  69. 69. Achieving economies of scale 100% Reserved capacity Time
  70. 70. Achieving economies of scale 100% On On-demand Reserved capacity Time
  71. 71. Achieving economies of scale 100% Spot On On-demand Reserved capacity Time
  72. 72. If your bid > spot price You get an instance
  73. 73. If your bid < spot price Your instance is terminated
  74. 74. Architecting for spot instances Decouple components Design for interruption Separate interactive & backend Use SQS, SWF processing Place data in a durable store such as S3, Use frameworks such as Elastic SimpleDB or DynamoDB MapReduce Save progress regularly
  75. 75. EMR with spot instances Scenario #1 Job Flow Duration: 14 Hours #1: Cost without Spot4 instances *14 hrs * $0.50 = $28
  76. 76. EMR with spot instances Scenario #1 Scenario #2 Job Flow Job Flow Duration: Duration: 14 Hours 7 Hours #1: Cost without Spot4 instances *14 hrs * $0.50 = $28
  77. 77. EMR with spot instances Scenario #1 Scenario #2 Job Flow Job Flow Duration: Duration: 14 Hours 7 Hours #1: Cost without Spot #2: Cost with Spot4 instances *14 hrs * $0.50 = $28 4 instances *7 hrs * $0.50 = $14 + 5 instances * 7 hrs * $0.25 = $8.75 Total = $22.75
  78. 78. EMR with spot instances Scenario #1 Scenario #2 Job Flow Job Flow Time Savings: 50% Duration: Cost Savings: ~22% Duration: 14 Hours 7 Hours #1: Cost without Spot #2: Cost with Spot4 instances *14 hrs * $0.50 = $28 4 instances *7 hrs * $0.50 = $14 + 5 instances * 7 hrs * $0.25 = $8.75 Total = $22.75
  79. 79. Spot marketBidding strategies
  80. 80. Spot bidding strategies Bid Distribution (for 3 months period) 20%Percentage of the Distribution 18% 16% 14% 12% 10% 8% 6% 4% 2% 0% Bid Price as Percentage of the On-Demand Price
  81. 81. Spot bidding strategies Bid Distribution (for 3 months period) 20%Percentage of the Distribution 18% 16% 14% 12% Bid near the RI 10% 8% hourly price 6% 4% 2% 0% Bid Price as Percentage of the On-Demand Price
  82. 82. Spot bidding strategies Bid Distribution (for 3 months period) 20%Percentage of the Distribution 18% 16% 14% 12% Bid above the spot price 10% 8% history 6% 4% 2% 0% Bid Price as Percentage of the On-Demand Price
  83. 83. Spot bidding strategies Bid Distribution (for 3 months period) 20%Percentage of the Distribution 18% 16% 14% 12% Bid near the 10% on-demand 8% price 6% 4% 2% 0% Bid Price as Percentage of the On-Demand Price
  84. 84. Spot bidding strategies Bid Distribution (for 3 months period) 20%Percentage of the Distribution 18% 16% 14% 12% 10% Bid above the on-demand price 8% 6% 4% 2% 0% Bid Price as Percentage of the On-Demand Price
  85. 85. Bid near the reserved hourly price You only pay for a full hour
  86. 86. Bid near the reserved hourly price You only pay for a full hour (if you are interrupted the hour is free)
  87. 87. Bid above the on-demand price Expect fewer interruptions
  88. 88. Bid above the on-demand price Expect fewer interruptions (only pay the spot price)
  89. 89. Implement cost aware architectureFlip from spot to on-demand as price dictates
  90. 90. Spot customers
  91. 91. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  92. 92. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  93. 93. $0.025 per hour DNS Elastic Load Web Servers Balancer Availability Zone
  94. 94. $0.025 per hour DNS Elastic Load Web Servers Balancer Availability Zone VS$0.06 per hour EC2 instance(small instance) DNS Web Servers + software LB Availability Zone
  95. 95. Consumers Producer SQS queue$0.01 per10,000 Requests($0.000001 per Request)
  96. 96. Consumers Producer SQS queue$0.01 per10,000 Requests($0.000001 per Request) VS $0.06 per hour Producer (small instance) EC2 instance Consumers + software queue
  97. 97. Software vs Services Software on EC2 AWS Services Pros: ELB, SNS, SQS, SES, SWF, DynamoDB etc Use custom features Pros: Pay as you go Cons: Scalability Requires an instance Availability SPOF High performance Limited to one AZ DIY administration
  98. 98. Summary
  99. 99. 5 Steps for cost optimizationElastic capacityInstance typesReserved instancesSpot instancesComplementary services
  100. 100. Where to go next
  101. 101. Useful linksaws.amazon.com/economicsaws.amazon.com/calculator
  102. 102. Useful links http://aws.amazon.com/whitepapers

×