amazon-web-servicesamazon-elbamazon-ecsamazon-alb

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,

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

Thanks!


Solution

  • 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.