Cost Optimisation in ECS: Integrating Spot Instances at Scale
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.
Related posts
- How OrderServ achieved up to 64% cost savings with multi-tenant ECS
AWS Architecture Blog mediumAdeptCognizant's OrderServ food-ordering platform moved from one dedicated ECS Fargate cluster per brand (21 microservices each) to a shared multi-tenant cluster. Isolation is enforced by a .NET tenancy library that resolves tenant context per request with AsyncLocal, routes data access with tenant prefixes and fails closed, backed by STS session-tag scoped credentials and per-tenant Valkey RBAC. Switching from Fargate to EC2 Auto Scaling warm pools on Bottlerocket cut scale-out from 5–7 minutes to 30–60 seconds and compute cost by 47–64% with Savings Plans, using a five-layer scaling strategy that includes per-tenant throttling. A FireLens and EventBridge crash-observability pipeline with EFS-persisted .NET mini dumps costs about $10/month per service, and passkeys replaced SMS OTP to cut authentication costs by 80%.
- Scale distributed AI workloads with Ray and Anyscale on Amazon EC2
AWS Architecture Blog easyNoviceRay, 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. There are three deployment paths: plain EC2 with EFA as the default, EKS with Karpenter for Kubernetes shops, and SageMaker HyperPod for long, failure-sensitive training runs. Each Ray library is mapped to suitable hardware: Graviton and Spot for Ray Data preprocessing, GPUs and Trainium for Ray Train, and Inferentia or Graviton for Ray Serve. Costs are layered as Savings Plans plus Spot (with head nodes kept On-Demand and checkpoint-based recovery), Capacity Blocks for scheduled training, and On-Demand for bursts.
- Outgrowing Lambda Functions, Not Lambda | Honeycomb
Honeycomb mediumAdeptHoneycomb 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. Lambda Functions had grown 5-8x more expensive per core-millisecond than EC2 because of an older Graviton mix and GB-second billing for network-bound waiting on S3. Agent-driven MCP queries also turned spiky load into a steady baseline. LMI is about 7.5x cheaper per CPU-second, but it bills for the whole fleet, so it only breaks even above roughly 12.5-14% utilization. Getting there required 16-way multi-concurrency, changes to GC, memory shedding and telemetry, capping the bang-bang autoscaler's max fleet size, and retry-then-spill routing plus query batching.
- Building an Auto-Scaling Lambda based on Github's Workflow Job Queue
ClickHouse mediumAdept
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. The Lambda compares current runners against in-progress and queued jobs, then scales up by roughly deficit/5 and down by reserve/2. The old rule (add a runner after 5 minutes above 97% busy) took hours to warm up groups of 50+ runners. The new approach launches jobs faster, saves compute when load drops, and keeps busy and active runner counts much more closely aligned.
- Infrastructure Observability for Changing the Spend Curve
Slack Engineering mediumAdeptSlack 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. Adaptive capacity standardized instance types and oversubscribed executors per instance after profiling vCPU and executor-count combinations, cutting costs about 70% and error rates about 50% while targeting 50% busy executors at peak. Circuit breakers in the Checkpoint orchestrator defer or cancel CI work when downstream services such as Jenkins, Vitess, Flannel or Search degrade, which stops cascading failures. Tracing the Cypress test runtime exposed runtime variables tied to flakiness, which had been burning roughly 90k compute hours a week.