Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Websocket scalability #67

Open
thetutlage opened this issue Sep 21, 2018 · 2 comments
Open

Websocket scalability #67

thetutlage opened this issue Sep 21, 2018 · 2 comments
Assignees

Comments

@thetutlage
Copy link
Member

From @ed-fruty on September 20, 2018 17:57

From the docs I read this:

The websocket server scales naturally on Node.js cluster without any 3rd party dependencies like Redis. Also there is no need of sticky sessions.

It's pretty cool (I can suggest it handles by master process) but, it's only scalability on the one machine.

How it can be scale for several servers ?
If one connection will serve by one node, and the second connection in another node. So we can't send message from first node socket to another node sockets, isn't it?

Can we resolve this with adonis ?

I mean schema something like this

With socket.io it's just makes through redis adapter.

Copied from original issue: adonisjs/core#955

@AddoSolutions
Copy link

AddoSolutions commented Dec 26, 2018

I was just looking into this as well. Does anyone have any ideas on how this might work? Has anyone done any thinking on how to implement this?

I would imagine that Adonis would not care about the load balancing part, but the state and stat management between instances.

So the #1 thing would be discovery and inter-connection of nodes.

Perhaps something like this, so that nodes can self-discover?
https://www.npmjs.com/package/node-discovery

With additional configuration options to manually specify other nodes to try first?

@okurichenko
Copy link

Hey. I was researching this a bit, and here are results:

  1. The easiest and most obvious way to share websocket messages between node workers has to be redis pubsub.
  2. It's not possible atm to use current addon interface because topic can be absent on the worker. Also, if you use broadcast method you should somehow avoid publishing message twice (via direct broadcast call and from a subscriber)

So what I've done was this package adonis-ws-redis-provider. If anybody could take a look and advice it would be perfect.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants