Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple web services on a single ECS cluster

If I have an ECS cluster with N distinct websites running as N services on said cluster - how do I go about setting up the load balancers?

The way I've done it currently is for each website X,

  • I create a new target group spanning all instances in the cluster
  • I create a new application load balancer
  • I attach the ALB to the service using the target group

It seems to work... but am want to make sure this is the correct way to do this

Thanks!

like image 258
maambmb Avatar asked Feb 04 '23 07:02

maambmb


1 Answers

The way you are doing it is of course one way to do it and how most people accomplish this.

Application load balancers also support two other types of routing. Host based and path based.

http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#host-conditions

Host based routing will allow you to route based off of the incoming host from that website. So for instance if you have website1.com and website2.com you could send them both through the same ALB and route accordingly.

http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#path-conditions

Similarly you can do the same thing with the path. If you websites were website1.com/site1/index.html and website1.com/site2/index.html you could put both of those on the same ALB and route accordingly.

like image 118
davis190 Avatar answered Feb 07 '23 10:02

davis190