Reputation: 8709
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?
Upvotes: 0
Views: 817
Reputation: 2693
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
Upvotes: 1
Reputation: 15343
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.
Upvotes: 0