Hello! I have a phoenix 1.4 app running nicely on a single dyno in Heroku.
I’ve tried scaling it up to 2 dynos and it also runs great, except for channels (that I use so background jobs can notify of finished processing, and the UI is updated).
It seems that when I have 2 dynos, some messages are not received on the channel. There’s no error, just lost messages.
I’m on Phoenix.PubSub 1.1.2 and using the Phoenix.PubSub.PG2 adapter - is it supposed to be compatible with Heroku? Should I use the Phoenix.PubSub.Redis adapter instead?
For anyone from the future who lands here, the next bottleneck will be on number of simultaneous connections. The wisdom is that you can have 50/dyno/heroku router - with the number of heroku routers being unknowable and the balancing strategy also unknowable. I also had issues with session affinity.
However, this connection limit did force me to use more smaller dynos, vs single larger dyno. I’m off to try the redis adapter for this reason as well.
You are very unlikely to run into that 50/dyno/heroku router limit since Heroku has so many routers. It is completely feasible to have 1,000+ simultaneous Phoenix Channels open on a single Heroku dyno. Here’s an example from people that have tested that: Websocket concurrent connections limit on Heroku - Stack Overflow
Now this will definitely be a problem, and of course since Heroku does not allow connections between dynos you cannot cluster on Heroku which could be used as a partial workaround for this (unless you get a Heroku Private Space which costs serious money)