Skip to content

Explain behaviour of RethinkDB when handling many change feeds requests for same query #778

Closed

Description

@danielcompton

Can someone explain how RethinkDB handles the case of many clients requesting change feeds with the same query? A chatroom is the canonical example I'm thinking of.

Is it more efficient on the DB server to only send one request and handle subscriptions at the app level? Or does the DB server dedupe these and efficiently dispatch the same values to all of them without doing calculations for each one?

http://www.rethinkdb.com/docs/changefeeds/ruby/ says

Changefeeds perform well as they scale, although they create extra intracluster messages in proportion to the number of servers with open feed connections on each write.

Does this mean that many changefeed subscriptions are collapsed into one query?

I'm ignoring the bandwidth required and transferring steps in this analysis, although they are important also.

Activity

  1. mlucy commented on May 25, 2015

    @mlucy
    Member

    We deduplicate changefeed messages inside the cluster, but not between the cluster and clients. So if you have 1000 clients connected to machine A and subscribed to changes on table T, and T is hosted on machine B, and then a change occurs on T, we send one message from B to A and then 1000 messages from A to your clients. So if your clients are on a third machine C, you'll get a lot of network traffic from A to C.

    You can mitigate this by running rethinkdb proxy on machine C and then connecting your clients to localhost (which will cause us to deduplicate messages from A to the proxy on C, and after that sending 1000 messages over the loopback interface is cheap).

    It might be worth elaborating on this a bit more in the docs. @chipotle, any thoughts?

  2. mlucy commented on May 25, 2015

    @mlucy
    Member

    (You could also mitigate it by running your clients on machine A, but some people like to keep their database servers separate from their application servers.)

  3. danielcompton commented on May 25, 2015

    @danielcompton
    ContributorAuthor

    Ahh, proxying the query is clever, I like that.

  4. chipotle commented on May 26, 2015

    @chipotle
    Contributor

    Issue #11 has been open since late 2013 on "document rethinkdb proxy" and most of the discussion in it has been along the lines of "do we even need this," so I haven't followed up on it. It might be a good idea for an engineer to write up a paragraph describing exactly what the proxy command does -- I don't fully understand it -- and add this to a few places in the docs, including changefeed docs.

    Also, #11 suggests that the 2.1 Raft implementation may render this all moot -- although if we're going to have to find a way to keep the 2.0 documentation around in addition to the 2.1 docs, we'll still need to document the way to do this in 2.0.

  5. stuartpb commented on Jun 1, 2015

    @stuartpb

    Should the drivers maybe do some changefeed deduplication themselves? Is there an open issue for that?

  6. danielcompton commented on Jun 1, 2015

    @danielcompton
    ContributorAuthor

    @stuartpb I'm not sure how much of a gain you could get from this, deduping across connections could be quite difficult. There's certainly a good argument for app level deduplication, although running a proxy server makes this much less necessary.

  7. chipotle commented on Jun 1, 2015

    @chipotle
    Contributor

    I've folded this into #11, since it seems the general advice is "use the mostly undocumented proxy command." The documentation will be added to the documentation on sharding/replication, which will be renamed "Scaling, sharding and replication," and cross-referenced from the changefeeds docs and changes API command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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