ECS Name resolution - Service Discovery, NLB, Service Connect?

0

Hi

I just started looking at ECS and I can see there are several methods of name resolution.

I can see at least three methods - service discovery, NLB, ServiceConnect with CloudMap . This is sligithly overwhelming and I am looking for some advice what is the best way for my scenario. We have an ECS Cluster and we chose to use Fargate for task allocation to keep things simple. Some tasks will need to resolve each other and this seems to be a straightforward when ServiceConnect is used. But what I also want to be able to do is to access tasks by DNS name. I can see this could be done by using NLB and selecting IP addresses of tasks as targets. This however seems a bit clunky to me as I would have to update target IPs manually everytime they are changed. So it seems that for access tasks by DNS name from outside the cluster, some other method is required. I imagine it is some sort of service mesh that updates DNS Records. I can see that Service Discovery is supposed to be able to. update DNS records but this method looks like a legacy one and not supported by terraform.

Could someone help me to understand what are the options here?

1 Answer
1

If you want multiple containers to work together (e.g., web server container, app server container, DB container), you can simply put all the container definitions into a single task definition and set one of them (e.g., web server) as the essential container. The containers can resolve each other on localhost interface.

https://docs.aws.amazon.com/AmazonECS/latest/userguide/fargate-task-networking.html

profile picture
HS
answered 7 months ago
  • Thank you, I did not know about this way. What are the benefits of using Service Connect over this simple method ?

  • Since I've never used Service Connect feature, I cannot provide a detailed scenario where Service Connect will be very beneficial.

    However, I found one case that you need Service Connect is that you need communication between different ECS Services, as mentioned in the following documentation. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect-concepts.html

    Service Connect is suitable for connections between Amazon ECS services within the same namespace.

    The reason you might prefer to separate tasks to different ECS services is that you might want to decompose your monolithic app to multiple general purposed microservices, and make them work together for some complex tasks as needed.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions