Does anyone know if it's possible to connect two or more nodes on EC2 by using Epmd or Gossip Strategy?

Does anyone know if it’s possible to connect two or more nodes on EC2 by using Epmd or Gossip Strategy?

I am using GitHub - bitwalker/libcluster: Automatic cluster formation/healing for Elixir applications and would like to connect by using simple strategies.

Is that possible? How?

I tried to open ports, set instances to the same security group and nothing is working, I can ping from one instance to another with success, but I can’t connect via Node.connect.

Should generally work. Double check your COOKIE values to ensure they are identical and that both nodes have long names…

E.g. how have you deployed the instances?

Thanks;

Well I’ve tried to open some ports according to some articles I’ve seen.

I’ve tried to use EPMD and GOSSIP. Cookie is the same for both EC2 instances. I can ping from one to another, but unfortunately I think there’s something missing to connect both.

I can’t connect manually via Node.connect either.

I simply created a small app just to play a little bit with it on AWS. I pushed them directly to run in the instances.

I got it working… the problem was the security group. If someone has the issue, try to setup your instances in the same subnet and learn about VPCs / Security Groups:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules-reference.html#sg-rules-other-instances

It works even with Gossip and EPMD:

Could you please share your setup?

I thought by default EC2 VPC doesn’t support broadcasting, and without it you’d have to know each instance dns name to connect to it. That is why there was libcluster ec2 strategy that was listing instances by tag

Hi @Athunnea you are right. I meant almost all strategies work, but you still need to respect their limitations, for example:

EPMD Local - I couldn’t make it work.

EPMD works, but you need to either hardcode or find a way to figure out the list of your instance’ IPs in advance. This guy created a lambda task to do it with ECS: Building an Elixir cluster on ECS | by Ryan Baker | Medium .

Gossip Works, but only in the same host… in my case, even my own host was not working.

libcluster ec2 works, but you need to expose your security via ex_aws and it will ping your tags every 2 or 3 seconds to get the list of private or public ips you have.

Don’t know if this works with EC2 or just Fargate, but AWS now offers DNS-based service discovery which can be hooked into libcluster so you don’t have to rely on tags, etc. See Libcluster in docker on aws elastic beanstalk - can't create a cluster for details. Again, I only tried on Fargate and it was super-simple…dunno if that translates to raw EC2 instances or not.