Last post May 27, 2016 09:02 AM by Fei Han - MSFT
May 24, 2016 07:21 AM|psa.azevedo|LINK
In our application we need to to send push notifications to a random number of clients. We have no way to create static groups for these users until right before sending the message, since the data is classified and can only be seen by the specific user.
We are trying SignalR to provide the notifications but have some doubts what would be the best way to implement the "Send" method.
We would like to know which one of the following options is the most scalable and performant solution for sending around 20 messages/sec to up to 3000 users that are randomly grouped.
Use the Clients method?
The "Clients" method in the API accepts a list of connection ids
Send the to each client?
Dynamically creating Groups for each message?
We can create groups for each message immediately before we send.
var groupName = Guid.NewGuid().ToString();
foreach (var clientId in clientIds)
await Groups.Add(clientId, groupName);
May 25, 2016 06:05 AM|Fei Han - MSFT|LINK
We have no way to create static groups for these users until right before sending the message, since the data is classified and can only be seen by the specific user.
It seems that you’d like to send specific message to specific user, if that is the case, you could map user to the connection id and persist that mapping, then you could loop through the collection of connection ids and call Clients.Client(clientId).NewMessage(message)
to send message to specific user randomly.
For more information about “Mapping SignalR Users to Connections”, please read this documentation.
May 25, 2016 06:26 AM|psa.azevedo|LINK
Hi Fei Han,
Thank you very much for your answer.
Yes the plan is to send specific messages but to a
set of users. This set of users will vary almost for every message that's why static groups is not a solution.
I was wondering if SignalR optimised the method Clients.Clients(collectionOfClientIds).NewMessage(message), that uses the MultipleSignalProxy, for scenarios where we want to send the same message to multiple users, instead
of iterating through all the users and send to each one individually.
Let me know your thoughts.
May 27, 2016 09:02 AM|Fei Han - MSFT|LINK
According to your description, you’d not like to send message to all connecting users, you want to broadcast message to a specific set of users. So the following approaches will not meet the requirement.
Clients.All.NewMessage(message); //send message to all clients
Clients.Group(groupName).NewMessage(message); //according to your description, you could not use SignalR Group
SignalR also enable us to broadcast message to clients in these two ways.
Clients.Client(clientId).NewMessage(message); //send a message to a particular user, use this, you need to loop through user collection
Clients.Clients(clientIds).NewMessage(message);//use this, you need to pass a connection id list to method
As far as I know, it seems that SignalR enable us to send message to client in four ways as I mention, if both of them could not meet your requirement, I have no more solution.