kostonstyle
Hi all
When I create a channel like:
channel "videos:*", Rumbl.VideoChannel
It will start a process for this channel? If yes, then only one process will handle all incoming events?
Thanks
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Quite interesting article Google brought me. Didn’t find any mentions about it here.
What do you think in general? Would you use togethe...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bratsche
I think there’s a minimum of 2 processes for any given channel. There will be one PubSub process, and one process for each client/user.
OvermindDL1
When you create a channel like that it creates no processes.
However let me go through the whole process as I understand it (from debugging and reading a good bit of the code).
The client websocket/longpolling connects to the ‘Socket’ that you made, that spawns off a new process, thus (1) process so far, for the open socket. That socket process then checks if it is allowed via your own code and such, do whatever you want, set assigns that will be given to all other topic processes too. That socket then checks the topic being connected to and spawns another new process for just that topic (and each new topic connected comes in the same socket process but then makes a new topic etc…). That topic process gets a copy of the socket assigns (this way you can do something like get the user from the database and store in an assigns for all topics to see). So at this point you have two processes, and one additional process for each extra topic.
kostonstyle
Thanks
webdeb
If I understood it correctly, then a topic like “user:*” will be spawned once for all users, each user/client has be connected over a persistent socket (which itself is a process, sure), but there will be no additional processes for each
user:#{id}topic, right?OvermindDL1
Nope, a process is spawned for each topic for each user. You can join more topics from inside a topic though, and ‘those’ will not create more processes, but anytime the javascript sides connects to a topic for every single user then a new process is created for that specific topic/connection by default.
webdeb
Hmm, thank you, so., this can potentially become expensive.. I am wondering, how we could send a single message to an opened socket connection, on a single
userstopic but to an explicit singleuser. I mean simply like responding is happening..I mean, you mentioned, that its possible to join an user to a topic without creating those processes.
So basically from JS
channel = s.join('users')Inside users one would join touser:idbut broadcasting messages wouldn’t reach the client side.. because there is no channel with the topicuser:iddefined..chrismccord
If you broadcast to a topic unique to a given user, say
"user:123", only that user will receive the message. If you’re asking how to message to a single user 123’s devices, then you can use Phoenix Presence, but we need to know more info to know what your exact usecase is. Generally it’s just fine to broadcast to a private user topic since you usually want all tabs/devices the user has joined to receive the message.OvermindDL1
Not too bad at all. Process’s are overall cheap.
You need to make at least one topic, as it is ‘that’ that can then join others without extra processes. You can broadcast just fine once the topic you made registers to them, like a socket joins
"users"but that topic also internally joins"user:#{id}", then you could broadcast to"user:#{id}"and that"users"topic would get it just fine.webdeb
Hi @chrismccord thank you for your attention. I’ll try to explain the use case:
10 users, each on a single device. All of them connect are connecting to the backend via WebSockets.
(For each of those is a socket process created, so far so good)
Now all of them join the
room:lobbyAnother process is created, which holds the state of the channel and all its meta data.Now each of them joins to the
user:uuidchannel.. As I understood, this will spawn another 10 processes (one for each wildcard uuid)So, basically, the main question is, how send a single message to a particular user, (I could store a map like
uuid -> socketon some generic topic likeusers?OvermindDL1
To a particular user? Just
MyEndpoint.broadcast("user:uuid", ...)as normal.What about that does not work for you?