Reputation: 3594
How much of a performance impact does having a large number of groups in SignalR cause? For example, take a social network where there are posts, and comments on those posts that need to be updated through a SignalR hub. Would it be better to create a group for each of those posts, and then send the comment update to that group, to send the comment update to all the clients and then have the client-side code decide whether to update or not, or is there another way I'm missing? Thanks!
Upvotes: 2
Views: 2538
Reputation: 18301
When you broadcast a message to clients via SignalR that message goes to a topic which then gets pushed down to a client/clients that are subscribed to the topic. Each connected client has a topic and each group has its own topic.
It's always faster to send to a group (that has more than 1 user associated with it) than to send to individual users. However, groups do take up memory. A single group is nowhere near as much memory as an entire user but if created in excess you can see the toll.
Therefore, the answer to your question is, it depends. Depending on the scale of your application and the implementations you could make lots of groups work, or not work.
For instance a situation where several people are commenting on a single post would definitely justify a group whereas a situation where a single person posted on their wall with 0 comments would not.
Hope this helps!
Upvotes: 3