0

I am developing an application using Phoenix framework which has 2 nodes. Application requires N number of scheduled tasks to be run every 10 minutes. Each task has it's own context. I need to connect the nodes so that I can balance the scheduled tasks between both the nodes. What would be a good approach for implementing this?

ed1t
  • 8,719
  • 17
  • 67
  • 110

2 Answers2

1

A process on one node can send a message to a process on any other node as long as the network environment is set up correctly (allowing connections between hosts on the correct range of ports, etc). The location-transparency guarantee of Erlang ensures this.

Checkout this article for more details: http://tjheeta.github.io/2014/12/05/elixir-inter-node-communication/.

Additionally, the Erlang Port Mapper Daemon (EPMD) (http://erlang.org/doc/man/epmd.html) handles the communications and can be configured to use a certain range of ports, etc:

iex --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_max 9001" ...

Also, see 9.8 and 9.9 at: http://erlang.org/faq/problems.html

Jason Harrelson
  • 2,683
  • 1
  • 16
  • 10
0

I believe the answers to this question may be what you're looking for.

TL;DR start each node with a cookie iex --cookie and then run Node.connnect from within iex to connect to the other node. I believe you can start each Phoenix app via iex -S mix

By the way, even via this procedure you cannot share processes between nodes. This is intentional--sharing processes between nodes would be dangerous, brittle and it would hinder scaling.

Community
  • 1
  • 1
Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
  • What do you mean by "sharing processes"? Processes between nodes can be linked, message each other, and so on transparently. http://erlang.org/doc/reference_manual/distributed.html – Cody Poll Mar 15 '16 at 16:54
  • I was referring to a phrase that he (@ed1t) used in his question. It depends on what he means by "sharing". I'd assume he meant the ability to access the same process from two nodes--which would, of course, be impossible. – Onorio Catenacci Mar 15 '16 at 17:13