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

Websockets over Redis #74

@kamilgregorczyk

Description

@kamilgregorczyk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions