Você está na página 1de 29

9/19/18

CMP202

Otimizando Amazon EC2


por Diversão e Lucro

Mv – Marcus Vinicius Ferreira | mvferr@amazon.com


Sr. SA, Public Sector, Education

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

1
9/19/18

Pilares de Otimização do Amazon EC2

Escolha tamanho Maximizar Escolha o Medir, Monitorar


adequado para elasticidade melhor modelo e Melhorar
instâncias preço

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

1º: Defina o tamanho adequado instâncias


Tamanho Adequado (Right Sizing)
• Selecione a instância com menor custo disponível que
atenda a necessidade da sua aplicação
• Acompanhe o consumo de CPU, RAM, Disco e Rede
para identificar instâncias que podem ser redimensionadas
• Utilize as métricas do CloudWatch e instale os plugins
para acompanhar consumo de RAM
• Considere instâncias t2/t2 Unlimited (burstable)
c4.large (2 VCPU 3.7 Gb RAM) - $0.1/hr
t2.medium (2 VCPU 4 Gb RAM), 4h 48min burst - $0.046/hr

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

2
9/19/18

Amazon EC2 – opções para todos os gostos

70 2017 launches:

60
• Compute optimized: C5, M5

52 • General purpose: T2 Unlimited

42 • Accelerated computing: G3, P3


• Memory optimized: x1e

23
• I/O optimized: I3, H1
• Programmable/FPGAs: F1
12 13
11
5
7 • Bare metal: I3.metal (Preview)
3
2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Compute: EC2 Instance Families

General Compute Burstable Dense-storage & GPU Memory


purpose optimized performance High-I/O optimized enabled optimized

M5 C5 T3 D2 I3/I4 G2 R3/R4

M4 C4 T2 P3 X1

3
9/19/18

Amazon EC2 T3: unlimited bursting by default

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

EC2: Famílias

Instance generation

c5.xlarge
Instance family Instance size

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

4
9/19/18

Tamanhos de Instâncias EC2: Famílias

≈ ≈ ≈

1 x c4.8xlarge 2 x c4.4xlarge 4 x c4.2xlarge 8 x c4.xlarge


~$1.60 ~$0.80 ~$0.40 ~$0.20

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Exemplo: Right Sizing


Analise o consumo de CPU, RAM, MEM e Disco das suas maiores máquinas

c4.2xlarge Linux Virginia


8 VCPU 32 RAM
$0.40/hr

c4.xlarge Linux Virginia


2 VCPU 8 RAM
$0.20/hr

75% economia

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

5
9/19/18

Ferramenta: EC2 Right Sizing

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

2º: Deixe seu ambiente mais elástico


No modelo tradicional de TI o cliente é obrigado a ajustar a sua capacidade com base na
sua necessidade dos próximos 3-5 anos
AWS permite que você ajuste a sua necessidade com a sua demanda atual

Desligue instâncias não-prod


• Identifique ambientes dev/test, não-prod e
desligue-os quando não há utilização
Utilize o AutoScaling
• Combine automaticamente capacidade
com a demanda do deu negócio

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

6
9/19/18

~62% da horas de um mês correspondem


a noites e finais de semana

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

EC2: Ligar/Desligar

Mês de 30 dias:
30 dias x 24h = 720 horas (100%)
Fim de semana:
08 dias x 24h = 192 horas ( ~26%)
Horario Comercial ( 7:00 às 19:00):
22 dias x 12h = 264 horas ( ~36%)
~ 62%
Horario Não Comercial:
22 dias x 12h = 264 horas ( ~36%)

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

7
9/19/18

Ferramentas para Elasticidade

Lambda Start-Stop EC2 Instance Scheduler


Opção faça você mesmo Opção semi-automática
https://aws.amazon.com/premiumsupport/kno https://aws.amazon.com/answers/infrastructur
wledge-center/start-stop-lambda-cloudwatch/ e-management/ec2-scheduler/

SkySaver (Skyone) Guide to Autoscaling


Solução 3P totalmente gerenciada Ajuste demanda e capacidade através do Autoscaling
https://aws.amazon.com/documentation/autoscaling/

Open Source
• Jenkins
• Rundeck
• Linux Crontab

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

3º: Modelos de Preço AWS

On Demand (OD) Instâncias Reservadas (RI) Spot


Pague por segundo sem Faça um compromisso de 1 ou 3 Capacidade ociosa, baixo
compromisso anos e receba um desconto custo e sem compromisso
significativo

Demanda instável, ainda Demanda estável, uso Demanda flexível,


desconhecida previsível stateless
Pague apenas pelo o que Até 75% vs OD Aprox. 90% vs OD
você precisa
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

8
9/19/18

Filosofia de Preços da AWS

Não é necessário Pague menos Pague menos à


investimento Pay as you go quando reservar medida que
inicial capacidade AWS cresce

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon EC2 On-Demand

Baixo custo e Desenvolvimento e Curto prazo,


flexível testes imprevisível

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

9
9/19/18

66x
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon EC2 Instances


256 igh
t er H and
e
us ry g
y Cl emo tora
128 or M gh S
Mem Hi
gh
64 Hi

32 ut
e
Memory (GB)

omp /O
C I
16 ter igh
lus d H
C an
se
8 rpo
Pu
al
4 ner U
CP
Ge High
2
o
1 no Mi
cr
Na
1 2 4 8 16 32 64 128

Amazon EC2 Compute Units

10
9/19/18

Reservas: quando fazer

28 dias x 24h = 672 horas


29 dias x 24h = 692 horas
30 dias x 24h = 720 horas
31 dias x 24h = 744 horas
...
365 dias x 24h = 8760 horas

365 dias x 24h = 8760 horas / 12 meses = 730 horas/mês


Média de consumo em 12 meses = 730 horas/mês

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon EC2 Instâncias Reservadas (RI)

Recomendado para
Desconto de até 75% 1 ano (payback 7-9 meses)
aplicações que estão
vs On Demand 3 anos (payback 10-18 meses)
sempre ligadas

Modelos de pagamento: No Upfront, Partial Upfront y Full Upfront


Serviços compatíveis: Amazon EC2, RDS, Redshift, ElastiCache, DynamoDB & CloudFront
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

11
9/19/18

Reservas: quando fazer: a cada 730 horas


Amazon RDS Auto Scaling

Multi-AZ

SQL master SQL slave

RDS: 1460 horas = 2 RI ( 730 + 730 )


EC2: 1600 horas x t2.large = 2 RI ( 2 * 730 ) +140 horas On-Demand

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

EC2 Pricing

https://aws.amazon.com/ec2/pricing/reserved-instances/pricing/
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

12
9/19/18

Reserved Instance: 1 yr

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Reserved Instance: 1 yr

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

13
9/19/18

Reserved Instance: 1 yr graph

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Reserved Instance: 1 yr – Break Even

42%

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

14
9/19/18

Reserved Instance: 3 yr – Break Even

62%

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

EC2 RI - Flexibilidade de Tamanho

Instancias reservadas Linux, regionais e com tenancy shared terão seus


descontos aplicados automaticamente entre todos os tamanhos da
família reservada, dentro da mesma região

Ou seja, 1 x m4.xlarge pode também representar na fatura:


2 x m4.large
½ x m4.2xlarge

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

15
9/19/18

Reserved Instances: flexibilidade

≈ ≈ ≈

½ Valor RI 1 x Valor RI 2 x Valor RI 4 x Valor RI

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Quais instâncias reservar? Cost Explorer

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

16
9/19/18

Quais instâncias reservar? Cost Explorer

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Amazon EC2 Spot

Spot: capacidade ociosa de EC2 que a AWS pode interromper após uma
notificação de 2 minutos

Baixo Custo Resultados mais Flexibilidade de


Fácil acesso
rápidos Recursos

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

17
9/19/18

Cada família de instância, cada tamanho de instância, em cada zona


de disponibilidade e em cada região é um Spot Pool independente
Capacidade Total região São Paulo

Shared
AZ1 Dedicated

AZ2 Shared

Dedicated

P2 C5 M5 I2 R4 D2
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Novo modelo de preços Spot

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

18
9/19/18

EC2 Spot

In 2013, Novartis ran a project that involved virtually screening 10 million


compounds against a common cancer target in less than a week. They calculated
that it would take 50,000 cores and close to a $40 million investment if they
wanted to run the experiment internally. Partnering with Cycle Computing and
Amazon Web Services (AWS), Novartis built a platform leveraging Amazon Simple
Storage Service (Amazon S3), Amazon Elastic Block Store (Amazon EBS), and four
Availability Zones. The project ran across 10,600 Spot Instances (approximately
87,000 compute cores) and allowed Novartis to conduct 39 years of computational
chemistry in 9 hours for a cost of $4,232. Out of the 10 million compounds
screened, three were successfully identified.

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

19
9/19/18

Amazon EC2 Spot Instances Use Cases


Containers & Stateless web
HPC & batch Big data
test/dev services

AdRoll have been able to


TLG Aerospace saw a 75% FINRA has saved up to 50% Yelp runs millions of tests
seamlessly scale their
reduction in the cost per from its on-premises every day with EC2 Spot
infrastructure, better serve
CFD simulation with solution, increased Instances. Yelp improved
customers across the globe,
Amazon EC2 Spot Instances. elasticity/scalability, and test result response time
and reduce our fixed costs
They were able to pass accelerated reprocessing from 2 days to 30 minutes
by 75% and operational
those savings along to their requests from months to and has also delivered a
costs by 83%.with AWS
customers and be more days with EC2 Spot large reduction in execution
solution, including EC2 Spot
competitive. Instances costs with Spot.
Instances

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

4º: Medir, Monitorar e Melhorar

1. Tageamento automático de recursos


2. Identificar recursos ligados 24/7
3. Identificar instâncias para downsize
4. Recomendar Instâncias Reservadas
5. Painéis de Controle
6. Reportar o que foi economizado

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

20
9/19/18

É essencial que seu ambiente esteja tageado

Por que?
• Transparência de gastos
Env = prod
• Alocação interna para o time correto

Env = test
Como fazer?
• Definir tags estratégicas (centro de custo, owner,
App = orders
ambiente, etc)
• Configurar tags estratégicas como mandatórias
• Automatizar

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Defina métricas e owners para a sua organização

Relacionadas a AWS Relacionadas ao seu negócio


% Instâncias desligadas $ por Usuário ou Transação
% horas EC2 cobertos por RIs $ por Impressão ou Click
% horas utilizadas das RIs $ por Aplicação ou Unidade de negócio
$ Economizado $ por Faturamento
$ Recursos não tageados $ por Desenvolvedor
# Recursos subutilizados # horas por $ investido

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

21
9/19/18

Use Cost Explorer para acompanhar utilização RI


maior utilização == maior economia ;)

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Ferramentas disponíveis

Cost Optimization:
EC2 Right Sizing
https://aws.amazon.com/answers/account-management/cost-optimization-ec2-right-sizing/

AWS Trusted Advisor


Disponível com suporte Business e Enterprise

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

22
9/19/18

Parceiros que podem te ajudar nessa jornada

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Parceiros: New Relic

https://discuss.newrelic.com/t/relic-solution-show-me-where-im-spending-the-money-aws-billing-new-relic/50451
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

23
9/19/18

Combinando os três modelos de preço


10
1. Use RIs para demandas
conhecidas e estáveis
8

2. Escale usando Spot, On-


Spot
Demand ou os dois 6 On-Demand
Reserved
3. Alguns serviços da AWS que
podem te ajudar: 4

AutoScaling, Spot Fleet,


ECS/EKS, Amazon EMR, 2
Thinkbox Deadline, AWS
Batch, AWS CloudFormation
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

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Padrões de Otimização por tipo de demanda


Novos negócios Demanda Interna TI

Teste e Desenvolvimento Data Science

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

24
9/19/18

Os 5 Pilares de Otimização de Custos na AWS

Escolha tamanho Maximizar Escolha o


adequado para elasticidade melhor modelo Medir e Controlar
instâncias preço

Repetir / Repetir

Obrigado!

Mv – Marcus Vinicius Ferreira | mvferr@amazon.com


Sr. SA, Public Sector, Education

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

25
9/19/18

Lowering TCO Through Optimization

COST

On- Lift &


Premises Shift

Lowering TCO Through Optimization

COST

On- Lift & Instance Improved Measure,


Premises Shift Right- Elasticity Monitor,
Sizing Improve

26
9/19/18

Lowering TCO Through Optimization

COST

On- Lift & Instance Improved Measure, Optimized


Premises Shift Right- Elasticity Monitor, EC2
Sizing Improve

Lowering TCO Through Optimization

COST

On- Lift & Instance Improved Measure, Optimized Storage Serverless Managed
Premises Shift Right- Elasticity Monitor, EC2 Optimization Architecture Services
Sizing Improve

27
9/19/18

Lowering TCO Through Optimization

COST

On- Lift & Instance Improved Measure, Optimized Storage Serverless Managed True AWS
Premises Shift Right- Elasticity Monitor, EC2 Optimization Architecture Services Optimized
Sizing Improve

Lowering TCO Through Optimization

E cono
mic C
ase Im
prov e
s thro
ugh O
ptimiz
ation
COST

On- Lift & Instance Improved Measure, Optimized Storage Serverless Managed True AWS
Premises Shift Right- Elasticity Monitor, EC2 Optimization Architecture Services Optimized
Sizing Improve

28
9/19/18

Lowering TCO Through Optimization

E cono
mic C
ase Im
prov e
s thro
ugh O
ptimiz
ation
COST

Typical TCO
Comparison

On- Lift & Instance Improved Measure, Optimized Storage Serverless Managed True AWS
Premises Shift Right- Elasticity Monitor, EC2 Optimization Architecture Services Optimized
Sizing Improve

Obrigado!

Mv – Marcus Vinicius Ferreira | mvferr@amazon.com


Sr. SA, Public Sector, Education

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

29

Você também pode gostar