Websocket subscriptions impact

#1

I am using adonis ws library on client (which is served by nuxt+vue, not adonis) to connect to adonis ws on server.

While working with both is great, I don’t know how it works internally. So, I am wondering what impact does a number of active subscriptions have on performance on client and server. I am talknig about a single connection from a single client but multiple subscriptions. I am not talking about number of connections here, so assume not too big number of users at any given time.

Can I feel safe to 10-30 active subscriptions on single client without overloading a client or server? How about hundreds? Could server (not client) handle even hundreds of thousands subscriptions if it is just thousands of connections (let’s say 64GB of RAM)?

0 Likes

#2

Having multiple subscriptions itself doesn’t have any overload, since AdonisJs uses a single connection under the hood. This is how it works under the hood.

When you create a subscription to a topic from the client, it will add some metadata to each message it sends. The server will then use that metadata to determine the controller or handler to call for that particular subscriptions.

So, under the hood, it’s a single connection with message exchanging with little extra data being sent in each package. The [websocket protocol] (https://github.com/adonisjs/adonis-websocket-protocol) repo explains the structure of that data clearly.

1 Like