Tal Borenstein
Tal Borenstein

Reputation: 43

Multiple SignalR (websocket) connections vs. A single connection with multiple hubs

Architecture Overview

Suppose we're building an SPA (Single Page Application) which depends on a couple of independent back-end systems. Basically a Microservice-ish implementation of SignalR-hubs.

Each of these back-end systems expose a separate SignalR endpoint with a separate set of hubs; The separation of these hubs across different back-end systems is intentional in design (again, because of microservice-ish considerations).

Basically, a single browser session to the app will have to maintain a separate SignalR-connection for every endpoint on which we depend and connections will be managed (opened and closed) on demand by the relevant components.

A flow that I can think of for an example would be:

A request initiates a booking request -> booking request is dependent on n number of services in order to be "completed" (whether succeeded or failed) -> due to asynchronous communication between those services, the client will receive a "booking id" for reference and will be notified on booking process through the relevant "booking-hub" that handles certain events from different services -> leaving the "booking component" will cause the hub to disconnect.

This leads us to the following questions:

Upvotes: 4

Views: 1624

Answers (1)

Kiril1512
Kiril1512

Reputation: 3611

In an architecture overview, is it a right assumption that also a SignalR hub(s) should be completely decoupled?

Many resources and what I have seen in my office implementations is that it is a better approach have a single Hub (core) that can be used from your services.

Are there any best practices regarding the usage of "websockets" in combination of a microservice-ish architecture?

It depends of how you want to handle your connection.

Are there any limitations (beside the fact that some browsers might limit the number of websocket connections) in manner of scaling?

Webscokets can have only 10 connections at once.

PS: About the connection, in the old SignalR version (@aspnet/signalr) the re-connections where managed by SignalR but in the new version you need to do that by yourself.

Upvotes: 1

Related Questions