Running multiple container using single EC2 instances in ECS

1

Hi, guys.

We are recently want to test on the AWS ECS service. Currently there are a total of 10 containers running on an EC2 which we deploy manually using composer. However, we would like to know if we use ECS service, can we still share the same EC2 or we need to provisioning instances for every services? If possible, we would like to share the similar EC2 across 10 containers. Is that possible?

Besides, we would also like to know how the load balancing would work if we deploy using the similar EC2 instance.

Thanks in advance.

Sky
질문됨 2년 전4770회 조회
1개 답변
1

Hi! So if you register the EC2 instance to join the ECS Cluster (and therefore also be an ECS Instance), you can create services that the cluster will then deploy in the available pool of ECS instances.

You can create deployment constraints, which are rules to say "deploy this service, in that way, on nodes that have these properties", which means it will try only create tasks if there are ECS instances, with available capacity, that match these rules to deploy the containers to.

If you prefer to not have to manage EC2 instances anymore, you can go down the Fargate route. If your use-case is simple enough, that's my go-to recommendation, as the (for on-demand) the maybe extra costs, IMHO, are outweight by simplicity. In that case each service' tasks gets their own host, which further ensures isolation.

If you want to scale in the same or similar way as Fargate does but not have to worry about provisioning the EC2 instances, you can create an Autoscaling Group and give that as a Capacity provider to your ECS cluster. ECS will then drive the autoscaling based on the number of needed containers for your services, and still allows to respect placement rules (strategies) as mentioned above.

When creating your service, you can specify which target groups of a load balancer you would like to register. ECS and ELB then communicate together to automatically register new containers, send traffic to them, or de-register these if unhealthy.

If you want to deploy with something docker-compose compatible which deals with creating all your services definitions, IAM rules, permissions etc, and lots more, try out ECS Compose-X | the labs.

profile picture
답변함 2년 전
  • So, does this mean that if I have a t3.medium instances. I can run all containers inside this instance without provisioning other instances?

  • Technically, yes, if that is the only instance you have. But now, know that the ECS agent will report the CPU/RAM available to the containers. So if you have 10 tasks which require a minimum of .5GB of RAM and .25 CvPUs, then would that all fit in the instance type ? You might run out of space really quickly.

    If you want HA with failover, running a cluster with a single instance is not quite the way to go.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠