Skip to content

10s → 0s

Zero-downtime ECS deploys

Fixed the ALB and shutdown timing behind an outage on every release.

Organisation
TransFi
When
2024 - now
Areas
Reliability, AWS, ECS Fargate

Problem

Every deploy to ECS Fargate caused a recurring outage of about 10 seconds. For a payments API, that means failed requests on every release.

It showed up as a short burst of failed requests during every task swap, which made each release something to schedule around instead of a routine change.

Constraints

  • No maintenance windows. Clients call the API around the clock from 40+ countries.
  • The fix had to work with normal rolling deploys on ECS Fargate, not a new deployment system.

What I built

I redesigned the release path so the load balancer, the shutting-down task and in-flight connections are coordinated.

Safe task replacement on deploy
  1. New task passes tuned health checks
  2. ALB deregisters the old task
  3. Connections drain
  4. App shuts down gracefully
  5. Old task stops
  • ALB target deregistration timing.
  • Task-termination timing.
  • Connection draining.
  • Graceful shutdown in the application.
  • Tuned health checks.

The root cause was ordering. An old task could stop before the load balancer had finished deregistering it, so requests were still routed to a container that was shutting down. The fix makes the app keep serving in-flight requests while the ALB drains connections, shut down gracefully only after that, and lets new tasks take traffic only once tuned health checks pass.

Outcome

  • The ~10s outage on every deploy went to zero.

What I'd do differently

I'd make zero downtime a tested property from the start. A deploy-under-load check in the pipeline would have caught the gap before it reached production.