SlideShare a Scribd company logo
1 of 40
Download to read offline
www.fivexl.io | hello@fivexl.io
AWS Spot Pricing
with
Terraform
www.fivexl.io | hello@fivexl.io
Основы Spot
Instance
www.fivexl.io | hello@fivexl.io
Spot Instance
Неиспользуемый в данный момент EC2 Instance, который
доступен по цене ниже цены по запросу
www.fivexl.io | hello@fivexl.io
Spot Instance pool
Набор неиспользуемых EC2 Instance с одинаковым
Instance Type, OS, AZ и сетевой платформой
www.fivexl.io | hello@fivexl.io
Spot Price
Текущая цена за Spot Instance за час. Устанавливается для
каждой AZ в зависимости от спроса и предложения
www.fivexl.io | hello@fivexl.io
Spot Max Price
Максимальная цена за Spot Instance за час, которую Вы
готовы платить.
www.fivexl.io | hello@fivexl.io
Что будет, если не указать Spot
Max Price?
По умолчанию будет использована On-Demand Price. Это
верно для AutoScaling Group, Spot Request, Spot Fleet
www.fivexl.io | hello@fivexl.io
При каких условиях будет
запущен Spot Instance?
Ваш Spot Instance запускается всякий раз, когда имеется
доступная емкость, а Spot Max Price для Вашего запроса
превышает текущую Spot price
www.fivexl.io | hello@fivexl.io
Рекомендации по
Spot Instance
www.fivexl.io | hello@fivexl.io
Готовность к
прерываниям
Оповещение придет за 2 минуты. Обработка событий
возможна через EventBridge
2 minutes for Terminate/Stop
Termination
notification
Terminated/Stopped
www.fivexl.io | hello@fivexl.io
EC2 Auto Scaling Group
и Spot Fleet
Spot Instance становятся устойчивыми и эластичными.
Что необходимо в условиях прерываний
www.fivexl.io | hello@fivexl.io
Разные Instance Type и AZ
Увеличивает вероятность запустить новый Spot Instance.
В некоторых случаях можно добавить прошлые
поколения
www.fivexl.io | hello@fivexl.io
Spot Instance Advisor
Поможет подобрать набор Instance Type для нужного
региона с наиболее оптимальным сочетанием
вероятности прерывания и ценой
www.fivexl.io | hello@fivexl.io
Allocation Strategy:
Capacity optimized
Автоматический выбор Spot Instance из наиболее
доступного Spot Instance Pool
www.fivexl.io | hello@fivexl.io
Allocation Strategy:
Lowest-price
Выбор Spot Instance из Spot Instance Pool с наименьшей
ценой. Рекомендуется для нагрузок, которые легко
прервать.
www.fivexl.io | hello@fivexl.io
Устойчивость с
Capacity rebalance
Новый Spot Instance будет запущен до прерывания за
счет EC2 Rebalance Recommendation сигнала
www.fivexl.io | hello@fivexl.io
EC2 Autoscaling Capacity rebalance
Rebalance
notification
triggers
instance
launch
New Instance bootstrapping
Termination - wait
ELB
deregistration
Terminated
New EC2
Old EC2
Rebalancing in progress
Lifecycle hook
New Instance
passes health
checks
www.fivexl.io | hello@fivexl.io
Spot Instance
Pricing
www.fivexl.io | hello@fivexl.io
Сколько же стоят Spot
Instance?
Cost Explorer - базовая информация всегда доступна
Spot Instance data feed - детальный отчет в S3
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
*Данные цены не являются реальными ценами на EC2 Spot Instance
www.fivexl.io | hello@fivexl.io
Charge = Spot Price
Цена, взимаемая за использование этого Instance
www.fivexl.io | hello@fivexl.io
Какие будут расходы, если не
указать Spot Max Price?
Расходы на Spot Instance будут переменными. С
максимумом в размере On-Demand Price.
www.fivexl.io | hello@fivexl.io
Может не указывать Spot Max
Price и иногда платить чуть
больше?
Spot price на отдельные Instance Type может сохранятся
на уровне On-Demand Price в течение нескольких
месяцев. “Чуть” может быть сильно большим, чем кажется
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
И что тогда? Отказываемся от
Spot Instance?
Для данной проблемы есть решение
Не открывая Spot Price History, автоматически, внутри CI
www.fivexl.io | hello@fivexl.io
www.fivexl.io | hello@fivexl.io
Автоматизация
расчета
Spot Max Price
spot_price_current_min
Хотя бы один Instance Type в хотя бы одной AZ
spot_price_current_optimal
Хотя бы один Instance Type во всех AZ
spot_price_current_max
Все Instance Type во всех AZ
spot_price_current_max_mod
Все Instance Type во всех AZ с повышенной
надежностью
www.fivexl.io | hello@fivexl.io
Исходные данные
AZ  Type r5.2xlarge r5d.2xlarge r5a.2xlarge
eu-central-1a 0.160 0.168 0.164
eu-central-1b 0.160 0.155 0.157
eu-central-1c 0.157 0.176 0.150
*Данные цены не являются реальными ценами на EC2 Spot Instance
www.fivexl.io | hello@fivexl.io
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5d.2xlarge"]
availability_zones_names_list = ["eu-central-1a"]
}
output "spot_price_current_min" {
value = module.ec2_spot_price.spot_price_current_min
}
Простой пример
- Просто получить текущую Spot Price для Instance Type и AZ
0.168
www.fivexl.io | hello@fivexl.io
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
}
output "spot_price_current_min" {
value = module.ec2_spot_price.spot_price_current_min
}
spot_price_current_min
- Минимальная текущая Spot Price
- Хотя бы один Instance Type в хотя бы одной AZ.
- ВАЖНО: все EC2 будут запущены только в одной AZ.
- В процессе изменения цен получаем каждый раз самый дешевый Spot Instance
- Вызывает более частые прерывания и требует частого запуска terraform apply
0.150
www.fivexl.io | hello@fivexl.io
Исходные данные
AZ  Type r5.2xlarge r5d.2xlarge r5a.2xlarge
eu-central-1a 0.160 0.168 0.164
eu-central-1b 0.160 0.155 0.157
eu-central-1c 0.157 0.176 0.150
*Данные цены не являются реальными ценами на EC2 Spot Instance
www.fivexl.io | hello@fivexl.io
spot_price_current_optimal
- Оптимальная текущая Spot Price
- Хотя бы один Instance Type во всех AZ
- Избавляет от проблемы с определением выгодного Instance Type для каждой AZ
- При изменении цен переключаемся постоянно на самый выгодной для каждой AZ
- В случае повышения цен начинаем терять AZ по одной
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
}
output "spot_price_current_optimal" {
value = module.ec2_spot_price.spot_price_current_optimal
}
0.160
www.fivexl.io | hello@fivexl.io
Исходные данные
AZ  Type r5.2xlarge r5d.2xlarge r5a.2xlarge
eu-central-1a 0.160 0.168 0.164
eu-central-1b 0.160 0.155 0.157
eu-central-1c 0.157 0.176 0.150
*Данные цены не являются реальными ценами на EC2 Spot Instance
www.fivexl.io | hello@fivexl.io
spot_price_current_max
- Максимальная текущая Spot Price
- Все Instance Type во всех AZ
- Решает проблему отсутствия Spot Instance за счет использования разных типов
- Допускает большую задержку между запусками terraform apply
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
}
output "spot_price_current_max" {
value = module.ec2_spot_price.spot_price_current_max
}
0.176
www.fivexl.io | hello@fivexl.io
Исходные данные
AZ  Type r5.2xlarge r5d.2xlarge r5a.2xlarge
eu-central-1a 0.160 0.168 0.164
eu-central-1b 0.160 0.155 0.157
eu-central-1c 0.157 0.176 0.150
*Данные цены не являются реальными ценами на EC2 Spot Instance
www.fivexl.io | hello@fivexl.io
spot_price_current_max_mod
- Модифицированная максимальная текущая Spot Price
- Все тоже самое что и у Максимальной текущей Spot Price
- Решает проблему небольших (5-10%) изменений Spot Price с сохранением контроля
расходов
- Доступно для spot_price_current_min, spot_price_current_optimal,
spot_price_current_max
module "ec2_spot_price" {
source = "fivexl/ec2-spot-price/aws"
version = "2.0.0"
instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"]
availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"]
сustom_price_modifier = 1.1
}
output "spot_price_current_max_mod" {
value = module.ec2_spot_price.spot_price_current_max_mod
}
0.185
www.fivexl.io | hello@fivexl.io
Но ведь разница получилась
~0.02$, зачем всё это?
~0.02$/час это ~14.5$ и это на каждый EC2 Spot Instance
И это без учета того что без Spot Max Price цена дойдет до On-Demand
www.fivexl.io | hello@fivexl.io
Области применения EC2 Spot
Price модуля
Всё что использует Auto Scaling Group: ECS Capacity
Provider, EKS worker nodes, GitLab self-hosted
● https://t.me/cageyv
● https://cageyv.dev/
● https://github.com/cageyv/
● https://www.linkedin.com/in/vladimirsamoylov/
● https://aws.amazon.com/ru/ec2/spot/instance-ad
visor/
● https://ec2spotworkshops.com/
● https://github.com/awslabs/ec2-spot-labs/
● https://github.com/aws/aws-node-termination-h
andler
● https://docs.aws.amazon.com/AmazonECS/latest
/developerguide/container-instance-spot.html
Contacts
Useful links
● https://github.com/fivexl/terraform-aws-ec2-spo
t-price
Terraform Module

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

AWS Spot pricing with Terraform

  • 1. www.fivexl.io | hello@fivexl.io AWS Spot Pricing with Terraform
  • 3. www.fivexl.io | hello@fivexl.io Spot Instance Неиспользуемый в данный момент EC2 Instance, который доступен по цене ниже цены по запросу
  • 4. www.fivexl.io | hello@fivexl.io Spot Instance pool Набор неиспользуемых EC2 Instance с одинаковым Instance Type, OS, AZ и сетевой платформой
  • 5. www.fivexl.io | hello@fivexl.io Spot Price Текущая цена за Spot Instance за час. Устанавливается для каждой AZ в зависимости от спроса и предложения
  • 6. www.fivexl.io | hello@fivexl.io Spot Max Price Максимальная цена за Spot Instance за час, которую Вы готовы платить.
  • 7. www.fivexl.io | hello@fivexl.io Что будет, если не указать Spot Max Price? По умолчанию будет использована On-Demand Price. Это верно для AutoScaling Group, Spot Request, Spot Fleet
  • 8. www.fivexl.io | hello@fivexl.io При каких условиях будет запущен Spot Instance? Ваш Spot Instance запускается всякий раз, когда имеется доступная емкость, а Spot Max Price для Вашего запроса превышает текущую Spot price
  • 10. www.fivexl.io | hello@fivexl.io Готовность к прерываниям Оповещение придет за 2 минуты. Обработка событий возможна через EventBridge 2 minutes for Terminate/Stop Termination notification Terminated/Stopped
  • 11. www.fivexl.io | hello@fivexl.io EC2 Auto Scaling Group и Spot Fleet Spot Instance становятся устойчивыми и эластичными. Что необходимо в условиях прерываний
  • 12. www.fivexl.io | hello@fivexl.io Разные Instance Type и AZ Увеличивает вероятность запустить новый Spot Instance. В некоторых случаях можно добавить прошлые поколения
  • 13. www.fivexl.io | hello@fivexl.io Spot Instance Advisor Поможет подобрать набор Instance Type для нужного региона с наиболее оптимальным сочетанием вероятности прерывания и ценой
  • 14. www.fivexl.io | hello@fivexl.io Allocation Strategy: Capacity optimized Автоматический выбор Spot Instance из наиболее доступного Spot Instance Pool
  • 15. www.fivexl.io | hello@fivexl.io Allocation Strategy: Lowest-price Выбор Spot Instance из Spot Instance Pool с наименьшей ценой. Рекомендуется для нагрузок, которые легко прервать.
  • 16. www.fivexl.io | hello@fivexl.io Устойчивость с Capacity rebalance Новый Spot Instance будет запущен до прерывания за счет EC2 Rebalance Recommendation сигнала
  • 17. www.fivexl.io | hello@fivexl.io EC2 Autoscaling Capacity rebalance Rebalance notification triggers instance launch New Instance bootstrapping Termination - wait ELB deregistration Terminated New EC2 Old EC2 Rebalancing in progress Lifecycle hook New Instance passes health checks
  • 19. www.fivexl.io | hello@fivexl.io Сколько же стоят Spot Instance? Cost Explorer - базовая информация всегда доступна Spot Instance data feed - детальный отчет в S3
  • 21. www.fivexl.io | hello@fivexl.io *Данные цены не являются реальными ценами на EC2 Spot Instance
  • 22. www.fivexl.io | hello@fivexl.io Charge = Spot Price Цена, взимаемая за использование этого Instance
  • 23. www.fivexl.io | hello@fivexl.io Какие будут расходы, если не указать Spot Max Price? Расходы на Spot Instance будут переменными. С максимумом в размере On-Demand Price.
  • 24. www.fivexl.io | hello@fivexl.io Может не указывать Spot Max Price и иногда платить чуть больше? Spot price на отдельные Instance Type может сохранятся на уровне On-Demand Price в течение нескольких месяцев. “Чуть” может быть сильно большим, чем кажется
  • 26. www.fivexl.io | hello@fivexl.io И что тогда? Отказываемся от Spot Instance? Для данной проблемы есть решение Не открывая Spot Price History, автоматически, внутри CI
  • 28. www.fivexl.io | hello@fivexl.io Автоматизация расчета Spot Max Price spot_price_current_min Хотя бы один Instance Type в хотя бы одной AZ spot_price_current_optimal Хотя бы один Instance Type во всех AZ spot_price_current_max Все Instance Type во всех AZ spot_price_current_max_mod Все Instance Type во всех AZ с повышенной надежностью
  • 29. www.fivexl.io | hello@fivexl.io Исходные данные AZ Type r5.2xlarge r5d.2xlarge r5a.2xlarge eu-central-1a 0.160 0.168 0.164 eu-central-1b 0.160 0.155 0.157 eu-central-1c 0.157 0.176 0.150 *Данные цены не являются реальными ценами на EC2 Spot Instance
  • 30. www.fivexl.io | hello@fivexl.io module "ec2_spot_price" { source = "fivexl/ec2-spot-price/aws" version = "2.0.0" instance_types_list = ["r5d.2xlarge"] availability_zones_names_list = ["eu-central-1a"] } output "spot_price_current_min" { value = module.ec2_spot_price.spot_price_current_min } Простой пример - Просто получить текущую Spot Price для Instance Type и AZ 0.168
  • 31. www.fivexl.io | hello@fivexl.io module "ec2_spot_price" { source = "fivexl/ec2-spot-price/aws" version = "2.0.0" instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"] availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"] } output "spot_price_current_min" { value = module.ec2_spot_price.spot_price_current_min } spot_price_current_min - Минимальная текущая Spot Price - Хотя бы один Instance Type в хотя бы одной AZ. - ВАЖНО: все EC2 будут запущены только в одной AZ. - В процессе изменения цен получаем каждый раз самый дешевый Spot Instance - Вызывает более частые прерывания и требует частого запуска terraform apply 0.150
  • 32. www.fivexl.io | hello@fivexl.io Исходные данные AZ Type r5.2xlarge r5d.2xlarge r5a.2xlarge eu-central-1a 0.160 0.168 0.164 eu-central-1b 0.160 0.155 0.157 eu-central-1c 0.157 0.176 0.150 *Данные цены не являются реальными ценами на EC2 Spot Instance
  • 33. www.fivexl.io | hello@fivexl.io spot_price_current_optimal - Оптимальная текущая Spot Price - Хотя бы один Instance Type во всех AZ - Избавляет от проблемы с определением выгодного Instance Type для каждой AZ - При изменении цен переключаемся постоянно на самый выгодной для каждой AZ - В случае повышения цен начинаем терять AZ по одной module "ec2_spot_price" { source = "fivexl/ec2-spot-price/aws" version = "2.0.0" instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"] availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"] } output "spot_price_current_optimal" { value = module.ec2_spot_price.spot_price_current_optimal } 0.160
  • 34. www.fivexl.io | hello@fivexl.io Исходные данные AZ Type r5.2xlarge r5d.2xlarge r5a.2xlarge eu-central-1a 0.160 0.168 0.164 eu-central-1b 0.160 0.155 0.157 eu-central-1c 0.157 0.176 0.150 *Данные цены не являются реальными ценами на EC2 Spot Instance
  • 35. www.fivexl.io | hello@fivexl.io spot_price_current_max - Максимальная текущая Spot Price - Все Instance Type во всех AZ - Решает проблему отсутствия Spot Instance за счет использования разных типов - Допускает большую задержку между запусками terraform apply module "ec2_spot_price" { source = "fivexl/ec2-spot-price/aws" version = "2.0.0" instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"] availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"] } output "spot_price_current_max" { value = module.ec2_spot_price.spot_price_current_max } 0.176
  • 36. www.fivexl.io | hello@fivexl.io Исходные данные AZ Type r5.2xlarge r5d.2xlarge r5a.2xlarge eu-central-1a 0.160 0.168 0.164 eu-central-1b 0.160 0.155 0.157 eu-central-1c 0.157 0.176 0.150 *Данные цены не являются реальными ценами на EC2 Spot Instance
  • 37. www.fivexl.io | hello@fivexl.io spot_price_current_max_mod - Модифицированная максимальная текущая Spot Price - Все тоже самое что и у Максимальной текущей Spot Price - Решает проблему небольших (5-10%) изменений Spot Price с сохранением контроля расходов - Доступно для spot_price_current_min, spot_price_current_optimal, spot_price_current_max module "ec2_spot_price" { source = "fivexl/ec2-spot-price/aws" version = "2.0.0" instance_types_list = ["r5.2xlarge", "r5d.2xlarge", "r5a.2xlarge"] availability_zones_names_list = ["eu-central-1a", "eu-central-1b", "eu-central-1c"] сustom_price_modifier = 1.1 } output "spot_price_current_max_mod" { value = module.ec2_spot_price.spot_price_current_max_mod } 0.185
  • 38. www.fivexl.io | hello@fivexl.io Но ведь разница получилась ~0.02$, зачем всё это? ~0.02$/час это ~14.5$ и это на каждый EC2 Spot Instance И это без учета того что без Spot Max Price цена дойдет до On-Demand
  • 39. www.fivexl.io | hello@fivexl.io Области применения EC2 Spot Price модуля Всё что использует Auto Scaling Group: ECS Capacity Provider, EKS worker nodes, GitLab self-hosted
  • 40. ● https://t.me/cageyv ● https://cageyv.dev/ ● https://github.com/cageyv/ ● https://www.linkedin.com/in/vladimirsamoylov/ ● https://aws.amazon.com/ru/ec2/spot/instance-ad visor/ ● https://ec2spotworkshops.com/ ● https://github.com/awslabs/ec2-spot-labs/ ● https://github.com/aws/aws-node-termination-h andler ● https://docs.aws.amazon.com/AmazonECS/latest /developerguide/container-instance-spot.html Contacts Useful links ● https://github.com/fivexl/terraform-aws-ec2-spo t-price Terraform Module