You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explain behaviour of RethinkDB when handling many change feeds requests for same query #778
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?
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.
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?
(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.)
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.
@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.
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.
Activity
mlucy commentedon May 25, 2015
We deduplicate changefeed messages inside the cluster, but not between the cluster and clients. So if you have 1000 clients connected to machine
Aand subscribed to changes on tableT, andTis hosted on machineB, and then a change occurs onT, we send one message fromBtoAand then 1000 messages fromAto your clients. So if your clients are on a third machineC, you'll get a lot of network traffic fromAtoC.You can mitigate this by running
rethinkdb proxyon machineCand then connecting your clients to localhost (which will cause us to deduplicate messages fromAto the proxy onC, 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?
mlucy commentedon May 25, 2015
(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.)danielcompton commentedon May 25, 2015
Ahh, proxying the query is clever, I like that.
chipotle commentedon May 26, 2015
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 theproxycommand 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.
stuartpb commentedon Jun 1, 2015
Should the drivers maybe do some changefeed deduplication themselves? Is there an open issue for that?
danielcompton commentedon Jun 1, 2015
@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.
chipotle commentedon Jun 1, 2015
I've folded this into #11, since it seems the general advice is "use the mostly undocumented
proxycommand." 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 andchangesAPI command.