Anda di halaman 1dari 50

CMP202

Otimizando Amazon EC2


por Diversão e Lucro

Vinicius Ferreira | mvferr@amazon.com


SA, Public Sector, Educationz
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
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.
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.
Amazon EC2 T3: unlimited bursting by default

© 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 G2 R3

M4 C4 T2 P3 X1
EC2: Famílias

Instance generation

c5.xlarge
Instance family Instance size

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Tamanhos de Instâncias EC2: Famílias

≈ ≈ ≈

1 x c5.8xlarge 2 x c5.4xlarge 4 x c5.2xlarge 8 x c5.xlarge

© 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

m4.2xlarge Linux Virginia


8 VCPU 32 RAM
$0.40/hr

m4.large Linux Virginia


2 VCPU 8 RAM
$0.10/hr

75% economia

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Ferramentas disponíveis para Right Sizing

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.
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.
~65% da horas de um mês correspondem a
noites e finais de semana

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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 Spot
Pague por segundo sem (RI) de 1 ou 3
Faça um compromisso 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 Até 75% vs OD Aprox. 90% vs OD
que você precisa
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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.
66x
© 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.
Amazon EC2 Instances
256
128
64
32
Memory (GB)

16
8
4
2
1
1 2 4 8 16 32 64 128

Amazon EC2 Compute Units


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 All Upfront


Serviços compatíveis: Amazon EC2, RDS, Redshift, ElastiCache, DynamoDB & CloudFront
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
RI Breakeven Point
Assuming c4.large Linux in US Virginia for Standard 1Y reservation

Savings vs
Annual Cost
On Demand

On Demand $ 876.00 -------


$0.100/hr

No Upfront $ 551.88 37%


$0.063/hr

Partial Upfront $ 525.60 40%


$0.060/hr

All Upfront 1 2 3 4 5 6 7 8 9 10 11 12
$ 516.84 41%
$0.059/hr On Demand NURI PURI AURI
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, 1x m4.xlarge pode também representar na fatura:


2x m4.large
½ m4.2xlarge

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Tamanhos de Instâncias EC2: Famílias

≈ ≈ ≈

1 x c5.8xlarge 2 x c5.4xlarge 4 x c5.2xlarge 8 x c5.xlarge

© 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.
Use Cost Explorer para acompanhar utilização RI
maior utilização == maior economia ;)

© 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.
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.
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.
Spot Instances: Spare compute capacity at scale
Spot: Últimos lançamentos

Acesso simplificado Set & Forget Pause & Resume


Utilize APIs existentes, Preços baixos e previsíveis Hibernation and stop-start
como EC2 RunInstances sem leilão

Spot Fleet: Defina quanto de capacidade você precisa e o Spot Fleet fará o resto

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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.
É essencial que seu ambiente esteja tageado

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

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

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Estabeleça na sua organização uma cultura com viés de
eficiência e otimização de custos

$
Crie incentivos através de reforço Assinale os custos par as áreas
(raises bar), feedback visual, adequadas de forma a incentivar um
gamification, etc. consumo mais consciente

Remova barreiras no processo de Documente melhores práticas,


execução de atividades de on-boarding e programas de
otimização treinamento
© 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.
Combinando os três modelos de preço
10
1. Use RIs para demandas
conhecidas e estáveis
8

2. Escale usando Spot, On-


On-Demand
Demand ou os dois 6 Spot
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.
Parceiros que podem te ajudar nessa jornada

© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
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
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

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

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
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.

Anda mungkin juga menyukai