Ideal Filtered Replication of Documents for specific user?

54 views
Skip to first unread message

Pankaj Jakhar

unread,
Mar 6, 2014, 1:36:11 AM3/6/14
to mobile-c...@googlegroups.com

Traun Leyden

unread,
Mar 11, 2014, 2:57:01 PM3/11/14
to mobile-c...@googlegroups.com
I looked at this, but I'm a little confused.  Are you just looking for an example for implementing filters on both the Couchbase Lite and CouchDB side?  (eg, the docs aren't clear?)

Btw there are known scaling issues with this approach.  @Jens do you have a link to a description which gives details?


On Wed, Mar 5, 2014 at 10:36 PM, Pankaj Jakhar <pankaj...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/3303bd1c-93be-4361-84cf-c404c4553c2b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jens Alfke

unread,
Mar 11, 2014, 3:19:33 PM3/11/14
to mobile-c...@googlegroups.com

On Mar 11, 2014, at 11:57 AM, Traun Leyden <traun....@gmail.com> wrote:

> Btw there are known scaling issues with this approach. @Jens do you have a link to a description which gives details?

I don’t know of any canonical written description of the problem (but @JChris might?) but the basics are:

* Filter functions are not super fast (written in JavaScript)
* The filter function has to be called once on every revision added to the database, for every user replicating with the database. So if you have 100,000 users, every new doc that gets added to the database will incur 100,000 executions of the filter function.

It’s probably not an issue for small sites, but doesn’t scale to big ones.

The alternative approach with CouchDB is to set up a database for every user, containing only the docs relevant to that user. The biggest problem with that is if documents are to be shared between users; then you have to set up a network of replications between the databases. Probably the cheapest way is to have a central db that has everything, and a pair of filtered replications between it and every user’s database. This has some pretty serious scaling limits too. Not only does a new update from a user wake up 99,999 pull replications once it arrives at the master database, but all of those replications are filtered so you have the same scaling issue as above.

This is pretty much exactly why we designed the Sync Gateway the way we did, with channels.

—Jens

Pankaj Jakhar

unread,
Mar 19, 2014, 4:48:50 AM3/19/14
to mobile-c...@googlegroups.com
So what can exactly do with the use of SyncGateway? Can you please clear me on all the points related to replication using SyncGateway? 

Can I write multiple filters on SyncGateway? Can I pass params to SyncGateway function?, etc. etc. Please provide me its full documentation so that I can make use of SyncGateway(including how it solves my problem)?

Jens Alfke

unread,
Mar 19, 2014, 10:03:13 AM3/19/14
to mobile-c...@googlegroups.com

On Mar 19, 2014, at 1:48 AM, Pankaj Jakhar <pankaj...@gmail.com> wrote:

So what can exactly do with the use of SyncGateway? Can you please clear me on all the points related to replication using SyncGateway? 
Can I write multiple filters on SyncGateway? Can I pass params to SyncGateway function?, etc. etc. Please provide me its full documentation so that I can make use of SyncGateway(including how it solves my problem)?


If you want specific information, ask specific questions.

—Jens
Reply all
Reply to author
Forward
0 new messages