P2P replication in mesh environment

44 views
Skip to first unread message

Yonah Forst

unread,
May 15, 2015, 11:30:08 AM5/15/15
to mobile-c...@googlegroups.com
I've been testing p2p replication (using bonjour for discovery) with a handful of devices and it's been working great. My question is: does replication scale? would it work to have as many as 100 active continuous pull replications and as many as 1,000 inactive replications?

The environment I'm designing for is a crowded area where iOS devices are communicating via wifi or BTLE. Each device make small changes to the database about once per-minute and needs to propagate these changes to all other devices. The idea is that this is decentralized and should work without connection to the internet (ambitious, I know...)

Would having this many active and inactive replications make them all ineffective? Are there any other limits which I might run into?

Cheers!

Jens Alfke

unread,
May 15, 2015, 12:09:52 PM5/15/15
to mobile-c...@googlegroups.com

On May 15, 2015, at 2:31 AM, Yonah Forst <yonah...@gmail.com> wrote:

The environment I'm designing for is a crowded area where iOS devices are communicating via wifi or BTLE. Each device make small changes to the database about once per-minute and needs to propagate these changes to all other devices. The idea is that this is decentralized and should work without connection to the internet (ambitious, I know…)

Mesh networks are tricky, and not just with Couchbase Lite. In a naïve implementation where every peer syncs with every other peer, the workload for each peer grows as O(N) and the amount of LAN traffic grows as O(n^2). Ouch! What you want instead is something like a spanning tree, which uses a small number of edges to interconnect all the peers while still keeping the path lengths short. Of course then you need coordination between the peers to create and maintain the pairwise connections that make up the tree, even as peers come and go. And the larger the network gets, the more churn there is as peers go on- and offline, and you have to keep that re-routing work from dominating the activity.

This has been done and there are real-world systems that use it (Zigbee, etc.) but from what I’ve seen, the algorithms are complex. It gets even more complex if you want to be robust against malicious peers trying to mess up the routing or inject false data.

But yes, the replication system is designed to handle arbitrary topologies including multiple hops and/or cycles.

—Jens

Yonah Forst

unread,
May 15, 2015, 2:01:43 PM5/15/15
to mobile-c...@googlegroups.com
Thanks for the reply, Jens!
Reply all
Reply to author
Forward
0 new messages