.netazuresignalrazure-signalr

Azure signalR and microservices


I’m quite confused and want some clarification

I’ve got a number of microservices which sit behind an api gateway.

I’ve got a react webApp which interacts with these apis via the gateway

The react app currently polls the API’s at a set interval to update or refresh its view of the world

Our client now wishes to have a more real-time approach. The simple solution here is to move to azure signalR backed with azure functions.

2 things.

  1. how does each api then tell this signalR service to send an update?

  2. is this best practice? Or should I have a signalR instance in each microservice? To me that sounds like a bad design? Since the gateway would be publishing a socket endpoint for each service.


Solution

  • It would be better to use one hub. The microservices behind the gateway would be clients of the hub. The applications that connect to the gateway would also be clients of the hub.

    The microservices would not be in the same group/groups as the client applications.

    When the services have an update they message the hub. A method on the hub then sends that to the group(s) of applications that consume the services.

    This would be a much simpler design than making every one of your services into a SignalR hub.