Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RethinkDB example not suitable for a multi-node cluster #4

Open
analytik opened this issue Sep 3, 2015 · 2 comments
Open

RethinkDB example not suitable for a multi-node cluster #4

analytik opened this issue Sep 3, 2015 · 2 comments

Comments

@analytik
Copy link

analytik commented Sep 3, 2015

Hi,

First of all, thanks for the sample! It's helping me to kickstart a project. However, if someone would run more than one replica of the socket.io server, horrible things would start happening, as instead of using a RethinkDB changefeed - which is one of the main reasons why people use RethinkDB in the first place - it just emits a message with changes which the specific server received. For example,

  • user 1 is connected with socket.io to server 1
  • user 2 posts data which get load balanced to server 2
  • server 2 saves data and emits a socket.io message
  • user 1 receives nothing

So all calls like messageService.sendCreateMessage('post', post); should be removed, and socket.io connection needs to be replaced with something like

function on_user_connected( ... ) {
    r.table("posts").changes().run(rConnection).then(function(cursor) {
        cursor.each(function (err, item) {
            ioServer.emit('post created or deleted or updated', JSON.stringify(item, null, 2));
        }
    };
}

I haven't worked up a specific solution yet, but I might post a more specific sample later.

@jmdobry
Copy link
Member

jmdobry commented Sep 3, 2015

I'm looking forward to your pull request :)

@analytik
Copy link
Author

analytik commented Sep 3, 2015

Heh. I'll see what I can do, I just wanted to make sure I'm not misunderstanding something about the application's design, as I'm new to Express. :)

@analytik analytik changed the title RethinkDB example fundamentally flawed in a cluster RethinkDB example not suitable for a multi-node cluster Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants