4

I am having a bunch of micro services running in AWS ECS fargate with ALB and Route53.Each micro service has an ALB with Route53.

Is there any kind of possibility where I can use only one ALB for all the microservices and route to their respective Route53 paths??

Here, I am not using EKS. Using AWS ECS Fargate.

Marcin
  • 215,873
  • 14
  • 235
  • 294
Megha
  • 77
  • 1
  • 7

1 Answers1

11

To server multiple Fargate services from a single ALB, you need to create different target groups (TGs) for them. So, each service will have its own TG, and ALB will forward traffic to respective TGs based on some listener rules.

Since you have Route53, a common choice is to create sub-domains, e.g.: service1.example.com and service2.example.com. You associate them as simple Alias A records with the same ALB.

On the ALB you will have single listener (e.g. HTTP 80), with different rules. For example:

  1. Rule one will be based on Host header equal to service1.example.com, with Action of Forward to TG1.
  2. Rule two will be based on Host header equal to service2.example.com, with Action of Forward to TG2.
  3. Some default rule compulsory (or use 2 as default rule).

And that's it. Any request from the internet directed to service1.example.com will go to your TG1 which is Fragete service1. Same for requests to service2.example.com.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Any extra charges for adding different rules for a ALB? @Marcin – Megha Sep 28 '20 at 11:02
  • 1
    @Megha ALB pricing includes [rules](https://aws.amazon.com/elasticloadbalancing/pricing/). But whatever it is, it should be much cheaper then running separate ALB's for each service. – Marcin Sep 28 '20 at 11:17
  • I have a doubt. With using one ALB to all the services, the urls that are linked to the LB will face any slowness while using?? – Megha Oct 05 '20 at 07:25
  • @Megha ALB scales with load. This is one of key reasons why people use manged load balancers from AWS - it can handle large traffic if needed. – Marcin Oct 05 '20 at 07:28
  • Ok. In case of getting very slow often. Can we increase the task CPU and memory utilization with increase in desired count as well?? – Megha Oct 05 '20 at 08:01
  • ALB is manged service, you can't change its CPU or memory. But ECS tasks and services are up to you, thus you can modify them as needed. – Marcin Oct 05 '20 at 08:02
  • Yes, by modifying the ECS tasks CPU and memory, the slowness issue will be solved? This is my doubt. – Megha Oct 05 '20 at 08:19
  • @Megha I'm not sure what do you mean. Maybe it would be good to make a new question, with the relevant details. If your tasks are slow there could be a lot of reasons, ranging from bugs in your application to insufficient cpu and/or ram. Thus its difficult to speculate on this. – Marcin Oct 05 '20 at 08:21