Search code examples
amazon-web-servicesamazon-ecsamazon-elbservice-discoveryaws-fargate

Using AWS ECS Service discovery with Application Load Balancer


When creating a fargate service in an ECS cluster, I'm using an application load balancer and I'm also using service discovery so my service has an endpoint. My question is: where should I send my requests, to the endpoint provided by service discovery or to the load balancer?

Also, how does the service discovery decides to which task it should send the request to?

I've searched AWS documentation but couldn't find a straight answer to this question.


Solution

  • Service Discovery is for network-level communication. Load balancer for client-server or in other word over internet communication.

    So if you want send request from outside of VPC then you will use a Load balancer.

    Or

    If you want send a request within VPC then you can use service discovery.

    how does the service discovery decides to which task it should send the request to?

    enter image description here

    So Route53 have IP against each fargate services.

    To understand how both service work together let have a look in this diagram

    enter image description here

    So for internal communication better to use service discovery to save time as call is on same network.

    For the client to server communication better to use Loadbalancer.

    amazon-ecs-service-discovery