<p>Load balancing will route the requests across tasks while autoscaling will increase or decrease the number of tasks based on the traffic.</p>
<p>starting new tasks when cpu threshold exceed is autoscaling, this can be setup with cloudwatch events.</p>
<p>you can load balance services based on rules and then route them to target groups. <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html" rel="nofollow noreferrer">read here</a></p>

CC BY-SA 4.0
2020-08-28T09:12:12.200Z
2020-08-28T09:27:53.323Z
2020-08-28T09:27:53.323Z
astroanu
<p>For a ECS service with launch type &quot;fargate&quot;, it is possible to configure a load balancer and auto scaling. I don`t understand, how those two types of scaling work in this case, and how they work together.</p>
<p><strong>My example</strong><br />
I define a task, and set the task size to &quot;0.25 vCPU&quot;. I then configure the service to use a load balancer, and auto scaling. I set the auto scaling to a maximum number of 4 tasks.</p>
<p><strong>My questions</strong></p>
<ol>
<li>I would expect, that the task is executed with 0.25 vCPU. When the task runs out of CPU, it starts another one, which uses another 0.25 vCPU. This is done until the maximum number of tasks is reached, this means a use and costs of 1vCPU in my example. Is this expectation correct?</li>
<li>What is the role of the load balancer? As I understand it, it is just needed for routing and https certfificate. Or does it play a role at scaling, too?</li>
<li>When I want to scale container based, then I need an own task definition for every container, right? And an own load balancer for every service? Is it possible to use one load balancer for multiple services?</li>
</ol>
<p>In which AWS docs I can read about those topics?</p>

<amazon-web-services><amazon-ecs><load-balance><fargate>
AWS ECS Fargate, auto scaling and load balancer
user1383029
# AWS ECS Fargate, auto scaling and load balancer

(Asked by: username_0 on 2020-08-25)

For a ECS service with launch type "fargate", it is possible to configure a load balancer and auto scaling. I don`t understand, how those two types of scaling work in this case, and how they work together.

**My example**  
I define a task, and set the task size to "0.25 vCPU". I then configure the service to use a load balancer, and auto scaling. I set the auto scaling to a maximum number of 4 tasks.

**My questions**

1. I would expect, that the task is executed with 0.25 vCPU. When the task runs out of CPU, it starts another one, which uses another 0.25 vCPU. This is done until the maximum number of tasks is reached, this means a use and costs of 1vCPU in my example. Is this expectation correct?
2. What is the role of the load balancer? As I understand it, it is just needed for routing and https certfificate. Or does it play a role at scaling, too?
3. When I want to scale container based, then I need an own task definition for every container, right? And an own load balancer for every service? Is it possible to use one load balancer for multiple services?

In which AWS docs I can read about those topics?

**Tags:** amazon-web-services, amazon-ecs, load-balance, fargate


---

## 1 answers

### Answer by username_1 on 2020-08-28. Score: 2

Load balancing will route the requests across tasks while autoscaling will increase or decrease the number of tasks based on the traffic.

starting new tasks when cpu threshold exceed is autoscaling, this can be setup with cloudwatch events.

you can load balance services based on rules and then route them to target groups. [read here](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)


---

