# Cost Optimisation in ECS: Integrating Spot Instances at Scale

DevFeed: [Cost Optimisation in ECS: Integrating Spot Instances at Scale](<https://devfeed.tech/articles/cost-optimisation-in-ecs-integrating-spot-instances-at-scale-19717.md>)

Original publisher: [Read original article](<https://deliveroo.engineering/2025/09/12/cost-optimisation-in-ecs.html>)

Author: Aakash Singhal

Published: 2025-09-12T00:00:00Z

Content type: article

Language: en

Sources: [Deliveroo](<https://devfeed.tech/sources/deliveroo.md>)

Topics: [Amazon Elastic Container Service](<https://devfeed.tech/topics/amazon-elastic-container-service.md>), [Amazon EC2](<https://devfeed.tech/topics/amazon-ec2.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [Cloud](<https://devfeed.tech/topics/cloud.md>), [Automation](<https://devfeed.tech/topics/automation.md>), [Resilience](<https://devfeed.tech/topics/resilience.md>), [Availability](<https://devfeed.tech/topics/availability.md>), [container](<https://devfeed.tech/topics/container.md>)

Tags: [automation](<https://devfeed.tech/tags/automation.md>), [availability](<https://devfeed.tech/tags/availability.md>), [aws](<https://devfeed.tech/tags/aws.md>), [container](<https://devfeed.tech/tags/container.md>), [cost](<https://devfeed.tech/tags/cost.md>), [cost-optimisation](<https://devfeed.tech/tags/cost-optimisation.md>), [ec2](<https://devfeed.tech/tags/ec2.md>), [ecs](<https://devfeed.tech/tags/ecs.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [load-balancer](<https://devfeed.tech/tags/load-balancer.md>), [resilience](<https://devfeed.tech/tags/resilience.md>), [scale](<https://devfeed.tech/tags/scale.md>), [stateless](<https://devfeed.tech/tags/stateless.md>), [storage](<https://devfeed.tech/tags/storage.md>)

## AI overview

Deliveroo describes how it integrated EC2 Spot Instances into Amazon ECS to reduce compute costs while maintaining service stability. The approach routes only eligible workloads to Spot capacity and uses criteria such as fast shutdown, task redundancy, statelessness, and load balancer deregistration timing.

## Source excerpt

At Deliveroo, we're always refining how we scale - especially when it comes to managing compute costs in the cloud. After optimising our Amazon ECS workloads with Reserved Instances and Savings Plans, we saw an opportunity to push further using EC2 Spot Instances, which offer up to 90% savings compared to On-Demand prices. But Spot comes with challenges: Their availability can fluctuate, and they can be terminated with just a two-minute warning. To unlock these savings without compromising service stability, we had to engineer a robust solution across infrastructure, workload qualification, and automation. The Challenge: Balancing Cost and Reliability Our ECS infrastructure initially relied entirely on On-Demand EC2 instances, provisioned through Auto Scaling Groups (ASGs) connected to ECS Capacity Providers. While reliable, this approach didn't take advantage of AWS's surplus compute capacity. We aimed to layer Spot Instances into our clusters, but selectively. Our goal was clear: route only eligible workloads to Spot capacity while ensuring no service degradation during unexpected terminations. Spot Instances: Power and Pitfalls Spot Instances provide dramatic cost reductions but introduce several operational caveats: Ephemeral by nature: AWS can terminate them at any time with a two-minute warning. Capacity variability: Availability depends on AWS's excess capacity in each AZ and can shift unpredictably. Scaling limitations: Auto Scaling may fail if the desired instance types are not currently available. To avoid introducing fragility into our stack, we established technical eligibility criteria that workloads must meet before being scheduled on Spot. Defining Spot Eligibility We formalised the following criteria to assess whether a workload could safely tolerate Spot interruptions: Fast Shutdown Support Constraint: stopTimeout must be < 120 seconds in the container definition. Reason: Ensures ECS has time to gracefully shut down the task before AWS's 2-minute te