0

Problem: I’ve got a container that requires a lot of CPU resources to complete in a required amount of time, and more than is available from FARGATE. The process would run as a batch job retrieving files from an S3 bucket. I’ve noticed that when using ECS\EC2 that I can select the instance type with the desired amount of CPU resources. Additionally, I would like to have no EC2 instances running when the task is not running and spin up the desired amount when needed, hence the need of autoscalling. At the moment I would be launching the task manually, and might need to launch several of the task simultaneously. Each of the the tasks would run on it’s own instance hence the distinctInstance placement constraint.

Question: In this type of setup would a load balancer be needed?

Lukasz
  • 2,476
  • 10
  • 41
  • 51
  • talking about ec2 instance aarchitecture not containers, if its single instance then all the traffic will go to that instance and based on traffic it might be overloaded or underperformed but if its multiple instances then should you use load balancer to distribute your load efficiently. since you have asg then asg will decide based on policy to scale in or scale out. having load balancer will just see health checks of instances issues by asg and forwards traffic efficiently. – Jatin Mehrotra Apr 28 '21 at 04:24

1 Answers1

1

It really depends what your application is doing. If it's serving traffic (e.g. a web service) than you need a LB to have a single point of entry and sprays load across different tasks. This assumes all tasks are serving the same purpose (e.g. one single web service). Your statement "a container that requires a lot of CPU resources to complete in a required amount of time" makes me think this is more of a batch job than a service service requests (in which case a LB may not be needed).

From an EC2 instance and ECS task scaling perspective this article may be of interest to you to get started thinking about how this could work.

mreferre
  • 5,464
  • 3
  • 22
  • 29
  • You are correct that it is a batch job. I've also been wondering if the LB would be needed to scale out, I can scale by low CPU utilization but scaling out is were I'm struggling. I was under the impression that the LB would have some type of setting/parameter that would assist with this but the fact that I want a `distinctInstance` placement policy makes me question the need of an LB. Also the link to the article you posted returns to this page. – Lukasz Apr 28 '21 at 14:09
  • Ouch. Sorry, I fixed the link to point to the article I intended to. In your case, there is no reason to have a LB if you don't have traffic coming in. You are right that the LB provides additional scaling metrics but again they are related to incoming traffic (e.g. scale on number of requests). Not applicable for you. – mreferre Apr 28 '21 at 14:25
  • 1
    In general there are two different scaling level here: how you scale the tasks (I think you have this figured and it seems like you have something-something scheduling these tasks - in other situations you'd need to build some logic if you want to scale on queue depth if your app is pulling messages from a queue etc). Then the next level of scaling is the capacity underneath (the blog I linked should help you with that). Also, we want to introduce larger task sizes so hopefully you will be able to use Fargate and this infrastructure scaling won't be required anymore. – mreferre Apr 28 '21 at 14:27