Rolling Deployments

Replace instances a few at a time so the service stays up throughout the deploy.

A rolling deployment updates your fleet gradually. Instead of stopping everything and starting the new version (which causes downtime), you replace one or a few instances at a time while the rest keep serving traffic.

How ECS does it

  • Start new tasks with the new image.
  • Wait for them to pass health checks and register with the load balancer.
  • Drain and stop old tasks.
  • Repeat until every task runs the new version.

Two settings control the pace: minimum healthy percent (how much capacity must stay up) and maximum percent (how much extra capacity to add during the roll).

Example

Example · json
{
  "deploymentConfiguration": {
    "minimumHealthyPercent": 100,
    "maximumPercent": 200,
    "deploymentCircuitBreaker": {
      "enable": true,
      "rollback": true
    }
  }
}

When to use it

  • A team deploys a new app version to 25% of EC2 instances at a time so the site stays up and the impact of a bad build is limited to a quarter of traffic.
  • An ECS service update rolls tasks over in batches so at least half the desired count stays healthy throughout the deployment.
  • A CodeDeploy deployment group uses a rolling strategy with a 15-minute wait period so each batch is monitored before the next batch is replaced.

More examples

ECS service rolling update config

Updates the ECS service so it keeps at least 50% of tasks healthy while running up to 200% capacity during the rollout.

Example · bash
aws ecs update-service \
  --cluster prod \
  --service myapp \
  --task-definition myapp:5 \
  --deployment-configuration \
    'minimumHealthyPercent=50,maximumPercent=200'

CodeDeploy rolling deployment config

Creates a CodeDeploy config that replaces 25% of the fleet at a time, keeping 75% healthy throughout the deploy.

Example · bash
aws deploy create-deployment-config \
  --deployment-config-name RollingQuarter \
  --minimum-healthy-hosts type=FLEET_PERCENT,value=75

Watch ECS rolling deploy progress

Blocks the script until ECS confirms all tasks are running and passing health checks after the rolling update.

Example · bash
aws ecs wait services-stable \
  --cluster prod \
  --services myapp
echo 'Rolling deploy complete — all tasks healthy'

Discussion

  • Be the first to comment on this lesson.