12

I'm sorry if this question sounds shortsighted but I cannot get my head around the difference between these two parameters.

AWS docs don't give me the answer either:

For Minimum number of tasks, enter the lower limit of the number of tasks for Service Auto Scaling to use. Your service's desired count is not automatically adjusted below this amount.

For Desired number of tasks, this field is pre-populated with the value that you entered earlier. You can change your service's desired count at this time, but this value must be between the minimum and maximum number of tasks specified on this page.

Can someone help me understand this please. I'm using Fargate launch type BTW.

Chris Williams
  • 32,215
  • 4
  • 30
  • 68
Red Bottle
  • 2,839
  • 4
  • 22
  • 59

2 Answers2

6

These two can appear to be similar values, however there's quite a major difference.

Minimum number of tasks is the small number of tasks that should ever exist. If this is 3 and it falls below 3 task then there are big problems (such as an AZ failure or host failure). This value should be able to cope with the minimal amount of load that you expect, in addition try to ensure it is highly available to support a single node failure.

Desired number of tasks is the amount of tasks ECS would like to be running, this will be in between the range of min and maximum but never exceeding the boundaries. This is not equal to the number of tasks running, it is simply the amount tasks that should be running (you may see this number increase before the autoscaing action kicks in).

Chris Williams
  • 32,215
  • 4
  • 30
  • 68
  • 3
    Thanks for the answer. Still confused when the number of tasks running will go below the Desired count? – Red Bottle Aug 12 '20 at 16:14
  • 1
    It should not ever go below the minimum number of tasks. I believe in deployments when minimum healthy percent is set to lower than 100% during deployments (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service.html) but not sure i it changes this metric then as the desired should still be equal to the number of tasks. In autoscaling you have in service and desired – Chris Williams Aug 12 '20 at 16:17
  • 1
    I'm also still confused here. The value for "desired tasks" seems to be respected regardless of the values for "min tasks" and "max tasks", or any of the application auto scaling settings, which I believe are only relevant during deployment. As a concrete example, if I set min=2 and max=3, AWS has no problem with me setting desired=1 or desired=4. It takes a minute or two but will ultimately start or stop tasks to reach the desired count regardless of the minimum and maximum. – HorsePunchKid Dec 17 '21 at 14:43
  • 2
    +1 to the confusion, I saw the same results as HorsePunchKid. We had desired tasks at 6 and autoscaling range was 6-10. Then bumped up autoscaling to min: 30 max: 60 but forgot to increase desired tasks and got very weird behavior. After deployment there were 30 tasks running (for hours) w no activity, I ran load tests and everything was fine. Next day I went to keep running some load tests and found that overnight the task count had dropped to 6 again! Not sure why it went up to 30 and didn't drop the first time, but the fact that it dropped later shows it CAN descale below minimum tasks. – ryoaska Sep 09 '22 at 03:14
1

I have observed even if desiredCount is set to be 1 and min = 6 and max =30 then after deployment desiredCount is set to 6. This corresponds to the docu.

the service scheduler respects the desired count at all times, but as long as you have active scaling policies and alarms on a service, Service Auto Scaling could change a desired count that was manually set by you.

If a service's desired count is set below its minimum capacity value, and an alarm triggers a scale-out activity, Service Auto Scaling scales the desired count up to the minimum capacity value and then continues to scale out as required, based on the scaling policy associated with the alarm. However, a scale-in activity does not adjust the desired count, because it is already below the minimum capacity value.

PhantomS
  • 420
  • 4
  • 14