AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Efficiency (ARC313)

300 views

Published on

Whether you’re a cash-strapped startup or an enterprise optimizing spend, it pays to run cost-efficient architectures on AWS. This session reviews a wide range of cost planning, monitoring, and optimization strategies, featuring real-world experience from AWS customers. We cover how to effectively combine Amazon EC2 On-Demand, Reserved, and Spot instances to handle different use cases; leveraging Auto Scaling to match capacity to workload; choosing the optimal instance type through load testing; taking advantage of Multi-AZ support; and using Amazon CloudWatch to monitor usage and automatically shut off resources when they are not in use. We discuss taking advantage of tiered storage and caching, offloading content to Amazon CloudFront to reduce back-end load, and getting rid of your back end entirely by leveraging AWS high-level services. We also showcase simple tools to help track and manage costs, including Cost Explorer, billing alerts, and AWS Trusted Advisor. This session is your pocket guide for running cost effectively in the Amazon Cloud.

Attendees of this session receive a free 30-day trial of enterprise-level Trusted Advisor.

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

No Downloads
Views
Total views
300
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
48
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

AWS re:Invent 2016: Running Lean Architectures: How to Optimize for Cost Efficiency (ARC313)

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Markus Ostertag, Head of Development, Team Internet AG, @osterjour Constantin Gonzalez, Principal Solutions Architect, AWS, @zalez November 30, 2016 Running Lean Architectures How to Optimize for Cost Efficiency ARC313
  2. 2. 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
  3. 3. Structure Business Architecture Operations
  4. 4. Business Goals “Pay as little as possible for what we use.”
  5. 5. 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 2006 Economies of Scale
  6. 6. AWS TCO calculator
  7. 7. AWS simple monthly calculator
  8. 8. AWS billing alerts
  9. 9. AWS billing console
  10. 10. AWS Trusted Advisor aws.amazon.com/premiumsupport/trustedadvisor/ Free with Business or Enterprise Support
  11. 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
  12. 12. Reserved Instances
  13. 13. Reserved Instances basics 1y RI Break even 3y RI Break even
  14. 14. Markus Ostertag Head of Development @ Team Internet
  15. 15. Who is Team Internet? Domain monetization business 30 people HQ in Munich, Germany Tech focused
  16. 16. Reserved Instances
  17. 17. Reserved Instances – our usage
  18. 18. Use the regional benefit Change existing Reserved Instances to scope “Region” Capacity reservation decoupled from cost optimization
  19. 19. Convertible Reserved Instances Use case: “(Very) Long running, but flexible”
  20. 20. Architecture Goals “Avoid waste as much as possible.”
  21. 21. 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!
  22. 22. Customer example Monday Friday End of Vacation Season 35% saved
  23. 23. Automate, automate, automate • AWS SDKs • AWS CLI • AWS CloudFormation • AWS OpsWorks • Netflix Janitor Monkey • Cloudlytics EC2 Scheduler • Auto Scaling
  24. 24. How Auto Scaling works
  25. 25. 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 … ]]}} } }
  26. 26. 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" } ] } }
  27. 27. Align resources with demand
  28. 28. 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?
  29. 29. Spot Instance example On-Demand: $0.24 $0.028 (11.7%) $0.026 (10,8%) $3.28 (1367%)
  30. 30. 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
  31. 31. Spot Bid Advisor
  32. 32. 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 Instances with one API call
  33. 33. “But my applications are too small for Auto Scaling!”
  34. 34. Amazon EC2 Container Service • Easily manage Docker containers • Flexible container placement • Designed for use with other AWS services • Extensible • Performance at Scale • Secure
  35. 35. 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
  36. 36. AWS Lambda Amazon S3 bucket events AWS Lambda Original object Compressed object 1 2 3
  37. 37. 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!
  38. 38. Optimizing database utilization
  39. 39. Database optimization through caching DynamoDB Amazon RDS DynamoDB Amazon RDS ElastiCache
  40. 40. Caching saves money DynamoDB reads Saved 3k reads per second (>20k reads per second in total)
  41. 41. Cache really everything! Cache hit ratio 25-30% Cache hit ratio 89-95% Without negative caching With negative caching Hit Miss
  42. 42. Cache invalidation “There are only two hard things in Computer Science: cache invalidation and naming things” -- Phil Karlton Two ways to cache: Time to Live (TTL) with invalidation Keep the cache in sync all the time
  43. 43. Synchronous writes Sync/check in the app with after-write return values DynamoDB ElastiCache write/update always write/update always
  44. 44. Uncoupled writes/invalidation Sync/updates via Lambda (uncoupled) DynamoDB ElastiCache write/update always no update Lambda DynamoDB Stream update
  45. 45. 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 Consider read (4K) vs. write (1K) sizes Use Amazon SQS to buffer over-capacity writes Resize capacity units dynamically
  46. 46. Amazon SQS can buffer requests
  47. 47. Dynamic DynamoDB
  48. 48. Offload popular traffic to Amazon S3 and/or Amazon CloudFront
  49. 49. Operational Goals “Focus on what you do best, let AWS do the rest.”
  50. 50. 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 Amazon Elasticsearch Service Amazon Kinesis SQS
  51. 51. 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
  52. 52. There is not 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
  53. 53. Advantages • No undifferentiated heavy lifting (= cost savings) • AWS operates the DB infrastructure for us • Simple and more granular scale out • No interference between RTB/Tracking and User/Stats
  54. 54. Let’s recap 1. Use AWS TCO/cost/billing tools 2. Use Reserved Instances 3. Avoid idle instances through automation 4. Use Spot Instances 5. Optimize database utilization 6. Pick the right tool for the job 7. Offload your architecture
  55. 55. But wait! There’s even more! https://youtu.be/SG1DsYgeGEk AWS re:Invent 2015 ARC302 Running Lean Architectures: Optimizing for Cost Efficiency • DynamoDB GSI Tweaking • Using CloudFront to avoid multi-region setups • Amazon S3 storage tiering • … and much more!
  56. 56. Thank you!
  57. 57. Remember to complete your evaluations!

×