---
title: "Cost Optimisation in ECS: Integrating Spot Instances at Scale"
description: "Deliveroo layered EC2 Spot Instances into its On-Demand ECS clusters by routing only workloads that pass hard eligibility rules: stopTimeout under 120 seconds, desiredCount of at least 2, stateless with no local or persistent storage, and ELB deregistration delay under 120 seconds."
url: "https://swe.quest/articles/cost-optimisation-in-ecs-integrating-spot-instances-at-scale-f52eab0cd796c438"
canonical: "https://deliveroo.engineering/2025/09/12/cost-optimisation-in-ecs.html"
source: "Deliveroo Engineering"
published: "2025-09-12"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["cost-optimization","cloud","capacity-planning","resilience"]
---

# Cost Optimisation in ECS: Integrating Spot Instances at Scale

A post on [Deliveroo Engineering](https://swe.quest/sources/deliveroo.md), published 2025-09-12, 5 min read, Case study. Original: [https://deliveroo.engineering/2025/09/12/cost-optimisation-in-ecs.html](https://deliveroo.engineering/2025/09/12/cost-optimisation-in-ecs.html)

## Summary

Deliveroo layered EC2 Spot Instances into its On-Demand ECS clusters by routing only workloads that pass hard eligibility rules: stopTimeout under 120 seconds, desiredCount of at least 2, stateless with no local or persistent storage, and ELB deregistration delay under 120 seconds. A custom Spot Placement Score metric, derived from AWS's Spot Placement Score API, drives near-real-time adjustment of the Spot percentage in capacity provider strategies, including disabling Spot during critical windows. A Step Functions orchestrator with Lambda determiner, updater and stability-checker steps, triggered by EventBridge, applies per-service strategies idempotently and validates health after each change. Even at a cautious 5-10% Spot share per cluster, compute costs dropped meaningfully with no observed impact on availability or latency.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)
- [Capacity planning](https://swe.quest/tags/capacity-planning.md) (Reliability & operations)
- [Resilience](https://swe.quest/tags/resilience.md) (Distributed systems)

## Prerequisites

- Amazon ECS capacity providers
- EC2 Auto Scaling Groups ([easy posts on Scaling](https://swe.quest/tags/scalability.md?difficulty=easy))
- AWS Step Functions and Lambda ([easy posts on Cloud platforms](https://swe.quest/tags/cloud.md?difficulty=easy))

## Keywords

Amazon ECS, EC2 Spot Instances, Spot Placement Score, AWS Step Functions, AWS Lambda, Amazon EventBridge, Auto Scaling Groups

## Related posts

- [How OrderServ achieved up to 64% cost savings with multi-tenant ECS](https://swe.quest/articles/how-orderserv-achieved-up-to-64-cost-savings-with-multi-tenant-ecs-935530e80e7948f4.md): AWS Architecture Blog · 2026-11-06 · Medium · 13 min read · Multi-tenancy, Cloud platforms, Cost optimization, Capacity planning, Observability
  Cognizant's OrderServ food-ordering platform moved from one dedicated ECS Fargate cluster per brand (21 microservices each) to a shared multi-tenant cluster.
- [Scale distributed AI workloads with Ray and Anyscale on Amazon EC2](https://swe.quest/articles/scale-distributed-ai-workloads-with-ray-and-anyscale-on-amazon-ec2-0c6441d44d076c17.md): AWS Architecture Blog · 2026-11-12 · Easy · 8 min read · ML platforms, Cloud platforms, Cost optimization, Model training, Inference & serving
  Ray, run as the managed Anyscale service inside your own AWS account, can carry a multimodal AI/ML pipeline from a single instance to multi-node clusters without code changes.
- [Outgrowing Lambda Functions, Not Lambda | Honeycomb](https://swe.quest/articles/outgrowing-lambda-functions-not-lambda-honeycomb-70c5a0734377ce87.md): Honeycomb · 2026-11-25 · Medium · 20 min read · Serverless, Cost optimization, Cloud platforms, Capacity planning, Observability
  Honeycomb moved most of its S3-backed query mapper compute from Lambda Functions to AWS Lambda Managed Instances, eventually cutting query costs 40-56%, though the switchover itself was easy and the savings came from months of tuning.
- [Building an Auto-Scaling Lambda based on Github's Workflow Job Queue](https://swe.quest/articles/building-an-auto-scaling-lambda-based-on-github-s-workflow-job-queue-4077ceef4fa411b3.md): ClickHouse · 2023-06-15 · Medium · 2 min read · CI/CD, Capacity planning, Cloud platforms, Serverless, Cost optimization
  ClickHouse replaced CloudWatch-alarm-based EC2 Auto Scaling for its self-hosted GitHub Actions runners with a Lambda that reads the workflow job queue, built from GitHub webhook events stored in ClickHouse, and sets desired capacity directly.
- [Infrastructure Observability for Changing the Spend Curve](https://swe.quest/articles/infrastructure-observability-for-changing-the-spend-curve-815f49a6391b6804.md): Slack Engineering · 2021-10-07 · Medium · 10 min read · CI/CD, Cost optimization, Observability, Resilience, Capacity planning
  Slack bent the growth curve of its webapp CI spend, which had been rising about 10% month over month, by using observability (dashboards, metrics and tracing) to drive three changes.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
