How do Phoenix Channels offline store work?

Iam new to Phoenix channels and just starting to discover its features, Iam so confused and have 2 questions :
Consider we have to build a social network which a user can subscribe for others :
1- Docs said that Phoenix will create one process per user per topic, so if someone has 2000 friends (an average case) then once he is connected, he will have an overload of 2000 erlang procs, this is not so expensive ?
2- When someone is offline, once he is connected, he will get all posts that he was missed, so is offline store exist in Phoenix channels ? and whose will be responsible for that ? since the PubSub service is excellent in such situations because it will receive all pushes from servers

1 Like

It’s one process per user. Channels are multiplexed on the socket connection

No, it’s up to You to decide where to store those missed messages, wherever You want. And on the next connection, user can retrieve and delete them from storage.

1 Like

Thank you @kokolegorille, in the docs I found that :
"To start communicating, a client connects to a node (a Phoenix server) using a transport (e.g., Websockets or long polling) and joins one or more channels using that single network connection. One channel server lightweight process is created per client, per topic. Each channel holds onto the %Phoenix.Socket{} and can maintain any state it needs within its socket.assigns.

Once the connection is established, each incoming message from a client is routed, based on its topic, to the correct channel server. If the channel server asks to broadcast a message, that message is sent to the local PubSub, which sends it out to any clients connected to the same server and subscribed to that topic."
I think that means there is a server for each topic

Probably in the same docs I found that…

A socket implementation that multiplexes messages over channels.

Also, I find useful to have a channel like this… users:id so the server can use it to forward all incoming communications to the user

1 Like

Yes, a client will use a single socket, but many servers per socket…
What I missed is the sub topics so thank you, I think this is the key point here, I think that will give me an idea how to store specific persistent data