I'm creating a web app/site in which my server will push real-time update to clients some info (using Pusher api).
So, the USERS that subscribe to a CHANNEL can receive the update when the server pushes updates to this CHANNEL.
However, (because of the nature of my application) there should be only one USER that receive a real-time update at a time. In other words, an update is actually targeted to not a specific CHANNEL, but a specific USER.
My current solution is: Each CHANNEL allows only one USER so the update targeted to the CHANNEL is for that one USER. Suppose I have 500 users then I need to have 500 channels. This requires setting up a lot of channels. Does that affect performance?
Is there any better way?
===============
The app is about receiving report about a disaster and assigning a nearest agency to take over and handle the situation. Each agency will be a user of the system (will be given a username). When the server receives a report, the nearest - only one - user (from the location where the report is lodged) will receive a real-time notification from the server.
At the moment there is not way to send a message to a user other than to have a channel per user.
My current solution is: Each CHANNEL allows only one USER so the update targeted to the CHANNEL is for that one USER. Suppose I have 500 users then I need to have 500 channels. This requires setting up a lot of channels. Does that affect performance?
This sounds exactly like the solution you are using right now e.g. the channel - and user - can be uniquely identified by channel name:
<user_name>-notification
Since channels are simply a routing mechanism there is no real overhead in having lots of channels; certainly 500 won't be any problem at all.
I'm assuming you are using private channels to ensure that only the allowed user can subscribe to their channel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With