Multi-region ECS: is service discovery possible across AWS regions?

0

Hello,

I have successfully deployed a Phoenix app to an ECS Cluster in eu-west-2 which uses libcluster to let nodes communicate with each other. That works (currently using a custom libcluster strategy).

I then deployed it to another region, us-west-2. That created a new ECS Cluster there.

I set up VPC peering so the two could communicate.

Finally, I created a Global Accelerator to route requests to the closest region.

All good.

However the issue is that currently the nodes in each ECS Cluster can only communicate with their peers in that same AWS region. That's because they have no way to know about ones in any other ECS Cluster (AWS region). I'm thinking there needs to be some form of DNS/endpoint that can be queried and report back the nodes/tasks within all ECS clusters e.g:

ecs: [
   strategy: Cluster.Strategy.DNSPoll,
   config: [
      polling_interval: 1000,
      query: "service.namespace", ...?
      node_basename: "app" ...?
   ]
]

Has anyone figured out cross-AWS-region service discovery to make something like this work?

I see that it is possible to add Service Discovery when a new service is created if using the classic AWS console. Would you e.g create a private DNS namespace in the first region, eu-west-2, and then somehow "join" that namespace from us-west-2? Since if each service creates a new namespace with a different name, the same DNS name could not be queried by the app ... and if it had the same name, it would resolve to use the regional service.namespace, again only reporting nodes within the same AWS region. Same problem as now.

The new AWS console doesn't have that option to enable service discovery. Instead it has a new option to enable Service Connect. Perhaps that can be used instead? But then that seems to use Cloud Map ... and that appears to be regional.

Thanks,

Greg

1 Answer
0

Hi, doesn't CloudMap provide you the right APIs to register each regional instance of your service and select it when you call DiscoverInstances ? You can even add your own custom attributes at registration time to improve the relevance of your selection.

https://docs.aws.amazon.com/cloud-map/latest/dg/what-is-cloud-map.html

https://docs.aws.amazon.com/cloud-map/latest/api/API_DiscoverInstances.html

profile pictureAWS
EXPERT
answered 10 months ago
  • Thanks. An ECS Cluster's namespace is integrated with Cloud Map. Default is API calls for discovery. I need DNS queries. To solve that I can go to Cloud Map directly, create namespace, and choose API & DNS. But the problem remains. I switch AWS region. That namespace is not in Cloud Map or listed for use by an ECS Cluster (for tasks to register themselves as part of). Looking at the console info, it says it "... must be in the same AWS Region as the Amazon ECS service and cluster". In order to discover nodes across regions I need a DNS service.namespace that can be queried from us-west-2 too

  • Amazon builds the AWS Regions in an isolated manner deliberately. You should think in the same manner. You don't want a problem in one region causing all your regions to not function. One approach would be to have separate name spaces in each region. You can use the regional endpoints to query both regions. However, I strongly recommend that you do not couple your regions together.

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