Should I create another related phoenix channel?

I’m making a project where users can talk in a chat application and I’m trying to understand Phoenix Channels.

As of now, the only real-time feature planned is the chat. But I may consider having a notification system (if someone mentions you, or sends you a direct message for example)

Are there advantages or disadvantages in having a single channel for several of your real-time features? Would it be better to create another phoenix channel for notifications and have the first channel communicate to the second one?

1 Like

There is no real limitation on how many channels You might use…

At least, I use one for notification, one per user (private channel) one for lobby etc.


Thank you that makes sense as channels are processes and processes are cheap in the beam

So each channel has like a different concern in your system

Unless you go through some work proxies or so that can limit it to 1 websocket connection per server (hence why my server is built to put everything over just one).

Plus it uses fewer server resources (not much, but still).

I thought there was only one socket connection, over which channels are multiplexed ?! :slight_smile:


Oh, I misread!

I was thinking multiple sockets. ^.^

But yeah, channels are super cheap regardless, can have many many of them over a single socket. ^.^


Yea, this is generally a good idea. It should lead to smaller Channels that could be composed more easily.

I recommend looking at a new Socket when your authentication needs change. For instance, a user portal has different authentication needs than an admin portal. I would have a Socket for the admins and then one for the users. If I had a feed:user_id topic, I would probably put that in the same Socket, different Channel, as the notifications:user_id topic.

1 Like