Rolling Deployments

The default deployment strategy replaces tasks gradually with the new revision.

By default ECS uses a rolling update. When you point a service at a new task-definition revision, ECS starts new tasks and stops old ones a few at a time.

Controlling the roll

  • minimumHealthyPercent — how many tasks must stay running during the deploy.
  • maximumPercent — how many extra tasks may run at once.

For example 100/200 keeps full capacity while doubling briefly; 50/100 deploys in place with less spare compute.

Example

Example · bash
# Register a new revision, then trigger a rolling update
aws ecs update-service \
  --cluster prod --service web \
  --task-definition web:8 \
  --deployment-configuration 'minimumHealthyPercent=100,maximumPercent=200'

When to use it

  • A team deploys a new API version by registering a new task definition revision and updating the service, letting ECS replace tasks gradually with zero downtime.
  • An SRE sets minimumHealthyPercent to 100 and maximumPercent to 200 so ECS always brings up new tasks before terminating old ones during a deployment.
  • An engineer enables the deployment circuit breaker so ECS automatically rolls back to the previous revision when more than 50% of new tasks fail to reach a healthy state.

More examples

Deploy New Revision via Service Update

Points the service at task definition revision 8 and forces a rolling replacement of all existing tasks with the new version.

Example · bash
aws ecs update-service \
  --cluster prod \
  --service api \
  --task-definition api:8 \
  --force-new-deployment

Set Deployment Configuration

Configures the service to keep 100% of healthy tasks running during deployment by doubling capacity temporarily — true zero-downtime rolling update.

Example · bash
aws ecs update-service \
  --cluster prod \
  --service api \
  --deployment-configuration \
    'minimumHealthyPercent=100,maximumPercent=200'

Enable Deployment Circuit Breaker

Enables the deployment circuit breaker with automatic rollback so ECS reverts to the last stable revision if the new deployment fails health checks.

Example · bash
aws ecs update-service \
  --cluster prod \
  --service api \
  --deployment-configuration \
    'deploymentCircuitBreaker={enable=true,rollback=true}'

Discussion

  • Be the first to comment on this lesson.