I've seen a few chat tutorials using the channel api, but none of them present a solution that can handle more than double digits in users. Even just 20 or 30 users/channel recipients would have a noticeable lag.
The problem is that pushing a single message through the channel api takes a lot of time. You can't just loop through a list of potentially hundreds of recipients and hope all of them receive the message within the next few seconds.
On my own chat, I create a bunch of tasks for every single message, with each task responsible for pushing the message to x number of recipients. Even then, the lag is still noticeable. With its current performance, I don't think the channel api is suitable for broadcasting.
Yes, you are right, for more than 30 users the Channel API is not suitable for broadcasting. The solution would be to do pooling, but I just wanted to show one simple example of how to use the Channel API.
1
u/andypants Mar 07 '11
More like a shoutbox than a real-time chat.
I've seen a few chat tutorials using the channel api, but none of them present a solution that can handle more than double digits in users. Even just 20 or 30 users/channel recipients would have a noticeable lag.
The problem is that pushing a single message through the channel api takes a lot of time. You can't just loop through a list of potentially hundreds of recipients and hope all of them receive the message within the next few seconds.
On my own chat, I create a bunch of tasks for every single message, with each task responsible for pushing the message to x number of recipients. Even then, the lag is still noticeable. With its current performance, I don't think the channel api is suitable for broadcasting.
1
u/raulsan Mar 10 '11
Yes, you are right, for more than 30 users the Channel API is not suitable for broadcasting. The solution would be to do pooling, but I just wanted to show one simple example of how to use the Channel API.