AWS ECS - Spot Instance Draining vs Fargate Spot
Tags: aws, cloud, fargate, ecs
Published: 2023-11-20 10:21:26

For most organisations, cutting costs on AWS is a constant struggle. The goal of this article is to assist you to understand key differences in between Spot Instance Draining versus Fargate Spot.

Amazon Web Services (AWS) offers different services for running containerized workloads efficiently. Two of them, ECS Spot Instance Draining and Fargate Spot, serve to different needs within the AWS ecosystem. Understanding their functionalities, benefits, and trade-offs is crucial for optimizing cost of containerised services.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uplo7w9lu2of2qfs6xne.png)



I assume that you already know what the Spot Instance is and how unreliable they are due to the their nature.

## AWS ECS Spot Instance Draining

Spot Instance provides us up to 90% off. ECS Spot Instance Draining enables the graceful handling of Spot Instance terminations. This feature allows ECS tasks to respond to termination notifications, ensuring applications complete tasks, preserve data integrity, and shut down gracefully before Spot Instances are reclaimed. But how?

**Termination Notifications**: You receive advance warnings of Spot Instance terminations, which enabling ECS tasks to prepare and complete ongoing processes.

> Automated Spot Instance Draining will automatically place Spot instances in “DRAINING” state upon the receipt of two minute interruption notice. ECS tasks running on Spot instances will automatically be triggered for shutdown before the instance terminates and replacement tasks will be scheduled elsewhere on the cluster. No new ECS service tasks will be started on the instances once the termination process has begun. ECS takes over the coordination of termination of tasks with the termination of the underlying EC2 instance using the inherent instance “DRAINING” functionality. The managed termination, scheduling of replacement tasks and graceful termination of the LB connections reduces the probability of service interruptions. This makes it easier for customers to use Spot instances as part of their ECS cluster.
[*](https://aws.amazon.com/about-aws/whats-new/2019/09/amazon-ecs-supports-automated-draining-for-spot-instances-running-ecs-services/)


## Fargate Spot

Fargate Spot offers a serverless computing experience by managing the underlying infrastructure, including Spot Instances, on behalf of the user. It provides up to a 70% discount off the regular Fargate price. This service combines the benefits of Fargate's serverless approach with the cost efficiency of Spot Instances, ensuring seamless scalability and cost savings. It comes with managed infrastructure advantage.

**Managed Infrastructure**: Eliminate the need for managing underlying instances, allowing users to focus solely on deploying and managing containerized applications.



## Choosing the Right Service for Your Use Case

- **Management Overhead**: Consider the trade-off between managing underlying infrastructure (ECS Spot Instance Draining) and adopting a fully managed service (Fargate Spot). If you don't need to access the underlying infrastructure go for Fargate.

- **Workload Characteristics:** Evaluate workload requirements and make the decision in accordance. Because with Spot Instances pricing is per hour whereas Fargate pricing is per hour based on requested vCPU, memory, Operating Systems, CPU Architecture1, and storage resources for the Task or Pod. 


---


I hope this quick recap was beneficial for you, providing a perspective that helps you to work along within the tools available within AWS for ECS-related operations.