AspNetCore SignalR Streaming Clarifications

750 Views Asked by At

I have been going through the recent signalr documentation, and i stumbled across the new feature called Streaming. I also, and i managed to get it running with a JS client. However, i am still not clear on when to use it.

1- Does ChannelReader stream data to a single client?

2- If yes, what is the difference than calling this.Clients.Caller.Invoke()

3- Lets say i am listening to an external realtime feed e.g. stock exchange, is it recommended to use signalr stream?

4- According to this post, the writer lives within a Task.Run(). So how is this scalable if i need to push a real time feed using streams to lets say 1000 clients? Are there any scalability concers of using signalr streams generally?

1

There are 1 best solutions below

0
On

1- Does ChannelReader stream data to a single client?

Yes.

2- If yes, what is the difference than doing this.Clients.Caller.Invoke()

You can only invoke a single method at a time (sequentially). As long as you are in an invocation, the rest will be queued for that connection until the previous one is finished. With streaming methods, you can start a stream and pump data to the client while still invoking other methods on the same hub.

3- Lets say i am listening to an external realtime feed e.g. stock exchange, is it recommended to use signalr stream?

Streams are for streaming data triggered from a client action. You can still do unsolicited (not from the client) streaming by just calling a method on the IHubContext.

4- According to this post, the writer lives within a Task.Run(). So how is this scalable if i need to push a real time feed using streams to lets say 1000 clients? Are there any scalability concers of using signalr streams generally?

It scales fine. The Task.Run kicks off the Stream but you're never holding a thread hostage.