How do you run Phoenix on more than one node?

1,661 views
Skip to first unread message

stonyol...@gmail.com

unread,
Aug 27, 2015, 6:41:26 PM8/27/15
to phoenix-talk
So, I'm sure this is possible, and according to Chris on an earlier message this is supposed to be easy.  But the client wants to translate an already built API (In PHP....) that he forecasts will need to spill over onto multiple boxes in order to handle the load. That's why he's looking into Elixir/Erlang, for the easy concurrency.

It seems that running a Phoenix instance with channels will be much better than trying to roll my own GenServer, etc. Problem: I've nowhere seen any examples of how to run a single Phoenix app on multiple nodes; nor how to design one to run on said nodes. Is this easily achievable with Phoenix out of the box (I'm thinking of a master/slave scenario, perhaps, with a central server that directs traffic--likely calls to a variety of Ecto models-- to various database hosts).  Or maybe I should run Riak or CouchDB and use their prebuilt scaling; maybe with a ejabberd box?

I'm just spitballing here; I don't know the clients setup enough yet to define the true task; but I've worked a bunch with Phoenix lately and I'd like to continue to use it; and it seems like this is the sort of thing that should be in Phoenix's wheelhouse.  Just no instructions on how to pull it off, sadly.

Thanks in advance!

benwil...@gmail.com

unread,
Aug 27, 2015, 10:27:38 PM8/27/15
to phoenix-talk, stonyol...@gmail.com
Well, what are you using Phoenix for? You mention it's replacing a PHP API which makes me think you're just using it as a web server, in which case running it on multiple servers is as hard as setting up a load balancer for them (trivial).

I agree there could likely be more said about multi-node setups using channels. But unless you're using websockets, channels aren't really something you're gonna use either. There are a lot of challenges that come with distributed stateful systems like channels, and while I believe there's some cool work going on with CDRTs to help make state eventually consistent, you're on your own there at the moment.

Are you using websockets? Are you trying to maintain state across a cluster of computers? Or is this just a web server API over a data store? If it's just the latter, just run phoenix on multiple boxes, there's no need to connect them.

Chris McCord

unread,
Aug 27, 2015, 10:37:33 PM8/27/15
to phoeni...@googlegroups.com
So Phoenix channels sit atop Phoenix.PubSub, which is a distributed pubsub system. When deployed on a cluster of machines, multinode broadcasts Just Work. You don’t have to configure anything. `broadcast socket, “foo:bar”, %{…}` will be delivered to all nodes for you (provided they are connected to the cluster). If not using distributed elixir to connect, nodes, you can make a one-line config change to use the Phoenix.PubSub.Redis adapter and redis will distribute the pubsub across your nodes. So if you are using channels, you load balance http across multiple phoenix nodes and pubsub takes care of the rest. Now, this is only for distributed PubSub. When you are talking about using Agent, GenServers, or registered processes in a distribute system, you need to make other considerations, but this applies to Elixir in general, not Phoenix. Hope that helps.

Chris

--
You received this message because you are subscribed to the Google Groups "phoenix-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-talk...@googlegroups.com.
To post to this group, send email to phoeni...@googlegroups.com.
Visit this group at http://groups.google.com/group/phoenix-talk.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-talk/2539e867-43c9-4d1f-8520-dc9763ad4177%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Louis Pilfold

unread,
Aug 28, 2015, 4:07:40 AM8/28/15
to phoeni...@googlegroups.com
Hello!

Perhaps a silly question, but what does a cluster mean here, and how
do I ensure instances of my application are connected to the cluster.

Thanks,
Louis
> https://groups.google.com/d/msgid/phoenix-talk/F766E4BD-0A4D-4D73-8CD6-0FEA69A77B7B%40chrismccord.com.

Jim Freeze

unread,
Aug 28, 2015, 9:47:36 AM8/28/15
to phoeni...@googlegroups.com

Louis Pilfold

unread,
Aug 29, 2015, 5:26:24 AM8/29/15
to phoeni...@googlegroups.com

k...@heroku.com

unread,
Aug 29, 2015, 10:18:02 AM8/29/15
to phoenix-talk, lo...@lpil.uk
I'm working my way through Learn You Some Erlang right now and it's really well written. I'm enjoying it long time.
Kevin

bansalak...@gmail.com

unread,
Dec 22, 2015, 11:04:37 AM12/22/15
to phoenix-talk
Can you help, how can I make a connect same phoenix apps running on multiple servers behind a LB. So that channel boradcast works for all clients connected with servers.

Yitzhak Bar Geva

unread,
Dec 30, 2015, 6:58:44 PM12/30/15
to phoenix-talk, stonyol...@gmail.com
This thread holds a lot in common with my (admittedly futuristic) thread, but take a look and tell me what you think.
Yitzhak
Reply all
Reply to author
Forward
0 new messages