51
COST OPTIMIZATION Ianni Vamvadelis Solutions Architect

Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Embed Size (px)

Citation preview

Page 1: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

COST OPTIMIZATION

Ianni Vamvadelis Solutions Architect

Page 2: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Multiple dimensions of optimization

Cost Performance Response time Time to market High-availability Scalability Security Manageability …….

Page 3: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Elastic Capacity

Page 4: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Elasticity is a fundamental property of the cloud that drives many of its economic benefits

Page 5: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

When you turn off your cloud resources, you actually stop paying for them

Page 6: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

6 am

Page 7: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

10 am

Page 8: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Web

Serv

ers

Hour

25% Savings

during a day

Page 9: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Availability Zone #2

Availability Zone #1

Auto Scaling group : App Tier

Auto Scaling group : Web Tier

Elastic Load

Balancer

www.MyWebSite.com

(dynamic data)

media.MyWebSite.com

(static content,

streaming media)

Amazon Route 53

(DNS)

Amazon EC2

Amazon RDS Amazon

RDS

Amazon S3

Amazon

CloudFront

Page 10: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Auto scaling options

Scaling base on Policy

Scale up and down base on metrics

Scaling Up policy - Double the group size if avg cpu > 80%

Scaling Down policy - Decrement by 10% if avg cpu < 30%

Scaling by Schedule

Scheduled Actions to meet known demand

Scheduled up to 31 days into the future

Recurring scheduled scaling activities.

Page 11: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29

Web

Serv

ers

Days of the Month

75% Savings

during a month

Page 12: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Instance Types

Page 13: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS
Page 14: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

On Demand

Page 15: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Choosing an Instance Type

Start with the EC2 instance type that best matches

memory requirements

virtual cores

Tune your instance type to optimise for cost

No need to get it right first time

Run across AZs

Smaller sizes give more granularity for deploying across AZs

Page 16: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Knowing your usage

Instance

Amazon CloudWatch Alarm

Free Memory

Free CPU

Free HDD

At 1-min

intervals

Custom Metrics

PUT 2 weeks

Page 17: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Horizontal Scaling

and

Vertical Scaling

Page 18: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Reserved Instances

Page 19: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Optimize by using Reserved Instances

Heavy Utilization RI

Medium Utilization RI

Light Utilization RI

1-year and 3-year terms

On-demand Instances

• Pay as you go

• Starts from $0.025/Hour

Reserved Instances

• One time low upfront fee + lower hourly cost

• $23 for 1 year term and $0.015/Hour

Spot Instances

• Requested Bid Price and Pay as you go

• $0.005/Hour as of today at 9 AM

Page 20: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Light Utilization RI

15-40% utilization

Lower costs up to 34%

Use Cases: Disaster Recovery, Weekly / Monthly reporting, Elastic Map Reduce

Page 21: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Medium Utilization RI

41-79% utilization

Lower costs up to 49%

Use Cases: Web applications, many heavy processing tasks, running much of the time

Page 22: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Heavy Utilization RI

> 80% utilization

Lower costs up to 58%

Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline

Page 23: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Best RI for Utilisation

$-

$2,000

$4,000

$6,000

$8,000

$10,000

$12,000

$14,000

$16,000

$18,000

Heavy

Medium

Light

O-Demand

Page 24: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Optimizing Cost with RIs

0

2

4

6

8

10

12

14

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

On Demand

Light Utilization RI

Medium Utilization RI

Heavy utilization RI

Page 25: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

http://aws.amazon.com/whitepapers

Page 26: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Spot Instances Bid on unused Amazon EC2 capacity.

Page 27: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Optimize by using Spot Instances

On-demand Instances

• Pay as you go

• Starts from $0.025/Hour

Reserved Instances

• One time low upfront fee + Pay as you go

• $23 for 1 year term and $0.015/Hour

Spot Instances

• Requested Bid Price and Pay as you go

• $0.005/Hour as of today at 9 AM

Page 28: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

What are Spot Instances?

Availability Zone

Region

Availability Zone

Unused

Unused

Unused

Unused

Unused

Unused

Sold at 50% Discount!

Sold at 56% Discount!

Sold at 66% Discount!

Sold at 59% Discount!

Sold at 54% Discount!

Sold at 63% Discount!

Page 29: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

What is the tradeoff?

Availability Zone

Region

Availability Zone

Unused

Unused

Unused

Unused

Unused

Unused

Reclaimed

Reclaimed

Page 30: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS
Page 31: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS
Page 32: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Architecting for Spot Instances

Decouple Components

Separate interactive and backend processing

Design for interruption

Use SQS, SWF

data in a durable store

save progress regularly

Page 33: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Use Cases for Spot

Analytics Financial Modelling

and Analysis

Media Encoding Geospatial Analysis

Testing Scientific Computing

Web Crawling Big Data

Page 34: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

#1: Cost without Spot 4 instances *14 hrs * $0.50 = $28

Job Flow

14 Hours

Duration:

EMR with Spot Instances

#2: Cost with Spot 4 instances *7 hrs * $0.50 = $14 +

5 instances * 7 hrs * $0.25 = $8.75

Total = $22.75

Scenario #1

Duration:

Job Flow

7 Hours

Scenario #2

Time Savings: 50%

Cost Savings: ~22%

Page 35: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Bidding Strategies

Page 36: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Optimize for Cost

Engineered application towards a cost

Set low maximum bid price to minimize costs

Comfortable if process takes longer or jobs were re-run

When interrupted, no charge for that hour.

Page 37: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

Page 38: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Price History Momentum

Monitor spot market price

Bid 10% above Average Spot Price of the Last Hour

Maximum bid of 80% of On-Demand Price

Expect fewer interruptions than Optimize for Cost

Page 39: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Price History Momentum

Page 40: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Discount over On-Demand

Bid around the On-Demand price

Use On-Demand instance when Spot Price exceeds On-Demand price (or slightly higher)

May pay more some hours, but on average they pay significantly less

This bidding strategy ensures a discount over On-Demand

Page 41: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Discount over On-Demand

Switch to

On-Demand Switch Back

to Spot

Substantial

Savings

Much lower

costs than

On-Demand

Page 42: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Strategy: Minimize Interruption

~57%

Savings

On Average

Substantial

Savings

Page 43: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS
Page 44: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Complementary

services

Page 45: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Web Servers

$0.095 per hour

(small instance)

Availability Zone

$0.028 per hour

Web Servers

Availability Zone

EC2 instance

+ software LB

Elastic Load

Balancer DNS

DNS

Page 46: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Producer

SQS queue

Consumers

Consumers

Producer

EC2 instance

+ software queue

$0.01 per

10,000 Requests ($0.000001 per Request)

$0.095 per hour

(small instance)

Page 47: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

Software v/s Services

SNS, SQS, SES

Pros

• Pay as you go

• Scalability

• Availability

• High performance

Software on EC2

Pros

• Custom features

Cons

• Requires an instance

• SPOF

• Limited to one AZ

• DIY administration

Page 48: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

1. Elastic Capacity

2. Instance Types

3. Reserved Instances

4. Spot Instances

5. Complementary services

Page 49: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

aws.amazon.com/economics

aws.amazon.com/calculator

Next Steps:

Page 50: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS
Page 51: Cost Optimisation in the AWS Cloud, Ianni Vamvadelis, Solutions Architect, AWS

THANK YOU