Skip to content
This repository has been archived by the owner on Aug 17, 2018. It is now read-only.

Websockets over Redis #74

Open
kamilgregorczyk opened this issue Jun 22, 2018 · 1 comment
Open

Websockets over Redis #74

kamilgregorczyk opened this issue Jun 22, 2018 · 1 comment

Comments

@kamilgregorczyk
Copy link

kamilgregorczyk commented Jun 22, 2018

Hi, some time ago I reported new issue in the iris repo but it got closed and my comment was deleted:/ then I found this repo and I think it has the same problem as iris has.

WebSockets should use some kind of a backend like Redis or RabbitMQ (or any other pubsub mechanism).

Why?

You see, let's imagine we have three clients:

CLIENT 1 <--->  |  INSTANCE 1 
CLIENT 2 <--->  |  INSTANCE 1

CLIENT 3 <--->  |  INSTANCE 2

Client 1 and 2 is connected to the 1st replica of our go app, and the 3rd one is connected to the 2nd instance of our go app.

If Client 1 calls some endpoint on instance 1 which then results in a published message (which should be received by everyone) over websockets then it will be delivered to only client 1 and client 2, the 3rd one won't receive it.

There's a good pattern (used in django's channels package) which uses some pubsub mechanism:

CLIENT 1 <--->  |  INSTANCE 1 | <--> REDIS
CLIENT 2 <--->  |  INSTANCE 1 | <--> REDIS

CLIENT 3 <--->  |  INSTANCE 2 | <--> REDIS

In that way when client 1 publishes a message, it is published not into websocket channel but to redis, then it gets received by every instance that listens on messages and is then forwarded from that channel to websockets.

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

No branches or pull requests

1 participant