660 likes | 886 Views
Optimizing for Cost in the Cloud. Jinesh Varia @ jinman Technology Evangelist. Multiple dimensions of optimizations. Cost Performance Response time Time to market High-availability Scalability Security Manageability ……. Optimizing for Cost.
E N D
Optimizing for Cost in the Cloud Jinesh Varia @jinman Technology Evangelist
Multiple dimensions of optimizations Cost Performance Response time Time to market High-availability Scalability Security Manageability …….
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
Elasticityis one of the fundamental properties of the cloud that drives many of its economic benefits
Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db)
25% Savings Optimize by the time of day
www.MyWebSite.com (dynamic data) Amazon Route 53 (DNS) media.MyWebSite.com (static data) Elastic Load Balancer Availability Zone #1 Auto Scaling group : Web Tier Availability Zone #2 Amazon CloudFront Amazon EC2 Auto Scaling group : App Tier Amazon RDS Amazon S3 Amazon RDS
50% Savings Optimize during a year
Auto scaling : Types of Scaling • Scaling 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
Auto scaling Best Practices • Use Auto Scaling Tags • Use Auto scaling Alarms and Email Notifications • Scale up and down symmetrically • Scale up quickly and scaling down slowly • Auto Scaling across Availability Zones • Leverage Suspend and Resume Processes
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.
Agg. CPU Instances
75% Savings Optimize during a month
End of the month processing • Expand the cluster at the end of the month • Expand/Shrink feature in Amazon Elastic MapReduce • Vertically 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)
Tip: Use “Reminder scripts” • Disassociate your unused EIPs • Delete unassociated EBS volumes • Delete older EBS snapshots • Leverage S3 Object Expiration
Basic recommendations on Instance Type • Choose the EC2 instance type that best matches the resources required by the application • Start with memory requirements and architecture type (32bit or 64-bit) • Then choose the closest number of virtual cores required • Scaling across AZs • Smaller sizes give more granularity for deploying to multiple AZs
AWS Support – Trusted Advisor – Your personal cloud assistant
Tip – Instance Optimizer Free Memory Free CPU Free HDD At 1-min intervals PUT 2 weeks Alarm Amazon CloudWatch Instance Custom Metrics “You could save a bunch of money by switching to a small instance, Click on CloudFormation Script to Save”
Optimizing for Cost… #1 Use only what you need (use Auto Scaling Service, modify–db) #2 Invest time in Reserved Pricing analysis (EC2, RDS)
m2.xlarge running Linux in US-East Region over 3 Year period Break-even point
Recommendations • Steady 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-Demand • Uncertain 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
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)
What are Spot Instances? Sold at 50% Discount! Sold at 54% Discount! Unused Unused Sold at 56% Discount! Sold at 59% Discount! Unused Unused Sold at 63% Discount! Sold at 66% Discount! Unused Unused Availability Zone Availability Zone Region
What is the tradeoff? Unused Unused Unused Reclaimed Unused Unused Unused Reclaimed Availability Zone Availability Zone Region
Save more money by using Spot Instances Reserved Hourly Price >Spot Price < On-Demand Price
Spot: Example Customers 57% 50% 63% 50% 56% 50% 66% 50%
Typical Spot Bidding Strategies Bid near the Reserved Hourly Price Bid above the Spot Price History Bid near On-Demand Price Bid above the On-Demand Price
1. Bid Near the Reserved Hourly Price $ $ $$ $ $ $ $$$$$$ $ $ $ $ $ $ $ $$$ $ $ $$$$$$$$$ $ $$$$$ $ $ $ $ 66% Savings over On-Demand
2. Bid above the Spot Price History 50% Savings over On-Demand
3. Bid near the On-Demand Price 50% Savings over On-Demand
4. Bid above the On-Demand Price 57% Savings over On-Demand
Amazon EMR (Hadoop): Run Task Nodes on Spot Amazon S3 Upload large datasets or log files directly Input Data Amazon S3 Data Source OutputData Amazon Elastic MapReduce Hadoop Cluster • TaskNode Amazon Elastic MapReduce Amazon SimpleDB Metadata Mapper Reducer Service • NameNode Code/ Scripts • TaskNode HiveQL Pig Latin Cascading Runs multiple JobFlow Steps • Core Node HiveQL Pig Latin Query • CoreNode HDFS BI Apps JDBC/ODBC
Amazon EMR: Reducing Cost with Spot #1: Cost without Spot 4 instances *14 hrs * $0.45 = $25.20 Job Flow Add 5 Spot Instances Scenario #2 Scenario #1 Allocate 4 instances Job Flow #2: Cost with Spot 4 instances *7 hrs * $0.45 = $12.60 + 5 instances * 7 hrs * $0.225 = $7.875 Total = $20.475 Duration: Duration: 14 Hours Time Savings: 50% Cost Savings: ~19% 7 Hours
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
Video Transcoding Application Example Amazon S3 Amazon S3 On-demand + Spot Amazon Elastic Compute Cloud Processed Data Output Bucket Input Bucket Raw Data Amazon EC2 Amazon SQS Amazon SQS Reports Website Job Completed Job Output Queue Input Queue Amazon EC2 Website (Job Manager) Metadata Status Logs Exceptions Amazon CloudWatch Amazon SimpleDB Amazon SimpleDB Amazon EC2 Intranet
Use of Amazon SQS in Spot Architectures VisibilityTimeOut Amazon EC2 Spot Instance
Optimizing Video Transcoding Workloads • Premium Offering • Optimized for Faster response times • No Delays Implementation • Invest in RIs • Use on-demand for Elasticity Maximum Bid Price >= On-demand Rate Get Instant Capacity for higher price • Free Offering • Optimize for reducing cost • Acceptable Delay Limits Implementation • Set Persistent Requests • Use on-demand Instances, if delay Maximum Bid Price < On-demand Rate Get your set reduced price for your workload
Architecting for Spot Instances : Best Practices • Manage interruption • Split up your work into small increments • Checkpointing: Save your work frequently and periodically • Test Your Application • Track when Spot Instances Start and Stop • Spot Requests • Use Persistent Requests for continuous tasks • Choose maximum price for your requests