---
title: "ECS task count changed during a deploy: auto scaling or the release? | Proofline"
description: "When an ECS task count moves during a deploy, Application Auto Scaling's activities for the service show whether a scaling policy changed it."
url: https://proofline.sh/learn/ecs-service-auto-scaling-during-deployment/
---

[Learning center](/learn/)

# ECS task count changed during a deploy: auto scaling or the release?

When an ECS task count moves during a deploy, Application Auto Scaling's activities for the service show whether a scaling policy changed it. If none matches the time, the desired count came from the release, a pipeline or a person. Application Auto Scaling pauses scale-in while an ECS deployment is in progress, so the direction of the change narrows the search before you read anything else.

Capacity overruns The Proofline team November 22, 2026 6 min read

## The signature and its nearby causes

During or just after a rollout, one of these appears:

-   Tasks stop with a reason of the form `Scaling activity initiated by (deployment deployment-id)`. AWS's 2023 guide says this reason marks tasks stopped because the desired count of the service went down.
-   More tasks start than the deployment needed, or the service's `desiredCount` reads differently after the rollout than before it.

[Stopped task reasons](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/stopped-task-errors-classic-console.html) · [The signature table](/learn/aws-deployment-failure-signatures/)

The stopped reason records that the desired count fell. It does not record who lowered it. Three sources can change the count:

-   **Application Auto Scaling.** A target tracking or step scaling policy changes `desiredCount` for the scalable dimension `ecs:service:DesiredCount`. Scale-in is turned off while an ECS deployment is in progress and resumes once it completes. Scale-out continues during a deployment unless you suspend it. [Troubleshooting service auto scaling](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/troubleshoot-service-auto-scaling.html) · [Service auto scaling](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html)
-   **The release or a person.** The desired count is set with `CreateService` and changed with `UpdateService`. A pipeline or infrastructure template that sends a `desiredCount` with each deployment sets the count to whatever the template holds. [Service fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Service.html)
-   **The scheduler's own replacements.** ECS replaces tasks that fail health checks or exit. Those stops carry their own reasons and appear in the [stop code guide](/learn/ecs-task-stop-codes/).

## Read the scaling activities for the deploy window

Application Auto Scaling keeps six weeks of activities. Each one has a `Cause`, a `Description`, start and end times, and a `StatusCode` of `Pending`, `InProgress`, `Successful`, `Overridden`, `Unfulfilled` or `Failed`. Adding `--include-not-scaled-activities` also returns the times it decided not to scale, with machine-readable codes such as `AlreadyAtMaxCapacity`. [DescribeScalingActivities](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_DescribeScalingActivities.html) · [ScalingActivity](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_ScalingActivity.html) · [describe-scaling-activities](https://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/describe-scaling-activities.html)

```
aws application-autoscaling describe-scaling-activities \
  --profile PROFILE --region REGION --service-namespace ecs \
  --scalable-dimension ecs:service:DesiredCount --resource-id service/CLUSTER/SERVICE \
  --include-not-scaled-activities \
  --query 'ScalingActivities[].{start:StartTime,end:EndTime,status:StatusCode,description:Description,cause:Cause,notScaled:NotScaledReasons[].Code}' \
  --output json --no-cli-pager
```

Then read the scalable target's limits and suspension state, and the policies that act on it. [ScalableTarget](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_ScalableTarget.html) · [SuspendedState](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_SuspendedState.html) · [ScalingPolicy](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_ScalingPolicy.html)

```
aws application-autoscaling describe-scalable-targets \
  --profile PROFILE --region REGION --service-namespace ecs \
  --scalable-dimension ecs:service:DesiredCount --resource-ids service/CLUSTER/SERVICE \
  --query 'ScalableTargets[].{min:MinCapacity,max:MaxCapacity,suspended:SuspendedState}' \
  --output json --no-cli-pager

aws application-autoscaling describe-scaling-policies \
  --profile PROFILE --region REGION --service-namespace ecs \
  --resource-id service/CLUSTER/SERVICE \
  --query 'ScalingPolicies[].{name:PolicyName,type:PolicyType,alarms:Alarms[].AlarmName}' \
  --output json --no-cli-pager
```

Finally, line the activities up against the deployment and the stopped tasks. `startedBy` on each task names the deployment that started it, and each deployment carries its own `desiredCount` and `createdAt`. [Deployment fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Deployment.html) · [Task fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Task.html)

```
aws ecs describe-services \
  --profile PROFILE --region REGION --cluster CLUSTER --services SERVICE \
  --query 'services[0].{desired:desiredCount,running:runningCount,deployments:deployments[].{id:id,status:status,definition:taskDefinition,desired:desiredCount,running:runningCount,created:createdAt,updated:updatedAt,rollout:rolloutState}}' \
  --output json --no-cli-pager

aws ecs describe-tasks \
  --profile PROFILE --region REGION --cluster CLUSTER --tasks TASK_ARN_1 TASK_ARN_2 \
  --query 'tasks[].{deployment:startedBy,started:startedAt,stopping:stoppingAt,code:stopCode,reason:stoppedReason,health:healthStatus}' \
  --output json --no-cli-pager
```

The API's service events come from the service scheduler. The console's event view also shows up to 10 recent Service Auto Scaling events, so it is a quick cross-check when the activities are hard to line up. [Service event messages](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages.html)

## What each result means

| Count change | Scaling activity at that time | Most likely source | Release involved? |
| --- | --- | --- | --- |
| Up during the rollout | `Successful` scale-out, cause naming a policy alarm | Application Auto Scaling | Only if the new revision raised the metric the policy tracks |
| Down during the rollout | None | `UpdateService` with a lower `desiredCount`: a pipeline, template or person | Yes, if the deployment's own update carried the count |
| Down soon after the rollout completed | `Successful` scale-in | Application Auto Scaling resuming scale-in | Usually not; the deployment scaled out and the policy is undoing it |
| Down or up with no activity, `SuspendedState` all false | None | A manual or pipeline change | Check who called `UpdateService` |

When no activity explains the change, CloudTrail's `lookup-events` can find recent `UpdateService` calls in the Region from the last 90 days, with the identity that made them. [lookup-events](https://docs.aws.amazon.com/cli/latest/reference/cloudtrail/lookup-events.html)

A scale-out during a rollout can come from the release. If the new revision uses more CPU per request, a target tracking policy on CPU scales out, and the extra tasks are a symptom of the revision's cost, not a capacity incident. Compare the policy's metric per task for the two revisions before treating the scale-out as background.

## An illustrative rollout, two outcomes

This fictional fixture follows the service `orders`, normally scaled between 4 and 12 tasks by a target tracking policy on CPU. At 09:58 the pipeline deploys `orders:58` as deployment `ecs-svc/2211`.

| Time | Record | Value |
| --- | --- | --- |
| 09:40 | Service | `desiredCount` 8 after a morning scale-out |
| 09:58 | Deployment `ecs-svc/2211` | Created with `desiredCount` 4 |
| 10:00 | Stopped tasks, `ecs-svc/1987` (old) | Four tasks, reason `Scaling activity initiated by (deployment ...)` |
| 10:00 to 10:20 | Scaling activities | None |

In this outcome, the release lowered the count. The pipeline's service definition holds `desiredCount: 4`, and each deployment resets the count to 4 regardless of the policy's 8. With scale-in paused during the deployment, Application Auto Scaling did not cause the stops. Four tasks carry the morning's load, so latency rises until the policy scales out again. The fix is in the pipeline: stop sending `desiredCount` on update, or send the current value.

In the second outcome, the 10:00 stops are absent. Scaling activities show a `Successful` scale-out at 10:06 from 8 to 10, and a `Successful` scale-in at 10:24, after the rollout completed. The new tasks used more CPU during warm-up, the policy reacted, and scale-in resumed once the deployment finished. The count change is the scaling policy's, and the release's only part is its warm-up cost.

## What to change, and how to confirm

Each of these is a change:

-   **Stop the pipeline from resetting the count.** Leave `desiredCount` out of deployment updates for a service that Application Auto Scaling manages. AWS notes that as long as policies are active, Service Auto Scaling can change a count you set by hand, so a reset is followed by a correction, with load on too few tasks in between. [Service auto scaling](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html)
-   **Suspend scale-out during deployments, if the warm-up spike is unwanted.** Set `DynamicScalingOutSuspended` on the scalable target with `register-scalable-target` before the deployment and clear it afterwards. A suspended target cannot react to real load during that time. [SuspendedState](https://docs.aws.amazon.com/autoscaling/application/APIReference/API_SuspendedState.html) · [register-scalable-target](https://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/register-scalable-target.html)

If the service has more running tasks than desired, unhealthy tasks still inside the health check grace period may be the ones stopped to reach the desired count. Their stop does not show that the grace period was too short. [CreateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html)

On the next deployment, read `desiredCount` before and after it, and read the scaling activities for its window. The count should stay where the policy left it unless an activity explains the change, and no stopped task from the old deployment should carry a scaling reason that no activity or intended update accounts for.

## Where the reading stops

Scaling activities say what Application Auto Scaling did, not what anyone else did. The stopped reason names a deployment, which identifies the tasks, not the actor. Not-scaled activities, which you get only with `--include-not-scaled-activities`, explain a count that the policy left alone. Stopped tasks expire after about an hour, while activities last six weeks, so capture the tasks first. [Stopped task retention](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/stopped-task-errors.html)

Task scale-in protection also blocks Service Auto Scaling scale-in; if old tasks stay after scale-in resumes, read the [protected tasks guide](/learn/ecs-protected-tasks-block-steady-state/).

## Questions

### Does ECS service auto scaling scale in during a deployment?

No. Application Auto Scaling turns off scale-in while an ECS deployment is in progress and resumes it once the deployment completes. Scale-out continues unless you suspend it.

### What does "Scaling activity initiated by (deployment ...)" mean on a stopped ECS task?

ECS stopped the task because the service's desired count went down. The reason names a deployment, not the cause of the change; read Application Auto Scaling's activities and recent `UpdateService` calls to find which one lowered the count.

### Why does my ECS service's task count drop every time I deploy?

If no scaling activity explains the drop, check whether the deployment sends a fixed `desiredCount` lower than the count auto scaling had reached. Remove the count from deployment updates, or set it from the service's current value.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [ECS deployment never reaches steady state: protected tasks](/learn/ecs-protected-tasks-block-steady-state/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [Which ECS task stops came from your deployment? Read the stop code](/learn/ecs-task-stop-codes/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
