Sushil
Sushil

Reputation: 31

AWS load balancer for multiple services

I have 12 containerized web services ( 12 distinct containers) running into my application. I want to deploy them to AWS. All 12 containers are significant in size and are expected to serve heavy demand so I won't deploy all the containers on a single container. In addition, I also want to have multiple containers of service # 4,5,6 since traffic is expected to be especially more for these 3 services. How can I use the AWS load balancer? How do I even load balance in this case? One easy solution might be to deploy all 12 containers in one EC2 but additional containers of service # 4,5 and 6 on 2nd EC2 instance and then replicate this same set up across 2 Availability Zones to ensure availability. But again I don't want to put all 12 services on one EC2 instance so this easy solution doesn't look like a feasible solution. Can someone share an idea around how load balancing can be achieved at different levels for specific containers when the count of services is so high?

For many days, I have tried hard to find an answer to this question but couldn't find guidance.

Upvotes: 3

Views: 11593

Answers (1)

Adiii
Adiii

Reputation: 59946

You can use Application Load Balancer, and it does not matter if run on EC2 container instance or on multiple instances.

How do I even load balance in this case?

You can Register ECS service with ALB so Load balancer will route traffic to the container service and it will not look for an EC2 instance, so you can run a replica of service on many EC2 instances. and you can register multiple ECS service with one load balancer.

how load balancing can be achieved at different levels for specific containers when the count of services is so high?

  • Application Load Balancers allow containers to use dynamic host port mapping (so that multiple tasks from the same service are allowed per container instance).

  • Application Load Balancers support path-based routing and priority rules (so that multiple services can use the same listener port on a single Application Load Balancer).

service-load-balancing

Now how one load balancer will route traffic to each service, that be can be done using two-approach

  • Host base routing
  • Path based routing

Each service can receive either host base traffic or path base traffic.

For example,

api.examle.com will route traffic to service A

auth.example.com will route traffic to service B

You can further detail here

enter image description here

Upvotes: 7

Related Questions