Data Sync

Creating Sync Groups

A sync group is a collection of devices organized into a distinct group, allowing you to limit connections to specific subsets of devices rather than the default behavior of connecting all devices sharing the same app ID.

Introduction

By default, devices with the same app ID automatically form a mesh network to connect. However, you can streamline sync processes, minimize unnecessary data transfer, and optimize resource usage by configuring sync groups within your app.

For example, the following graphic illustrates two distinct restaurants identified by their location IDs: 7890 and 1234. When a peer establishes its identity with the Big Peer, it includes its location ID as part of the authentication callback.

Now, the two groups maintain isolated mesh networks:

Document image


Access Controls by Group

Sync groups are an optimization, not a security control — if a connection is created manually, such as by specifying a connecting transport, then devices from different sync groups will still sync as normal.

To enforce access controls by group, for instance, two groups of devices, each accessing different datasets, use Ditto's permissions system. (See End-User Access)

The syncGroup parameter provides this functionality. A device can only ever be in one sync group, which by default is group 0. Up to 2^32 distinct group numbers can be used in an app. Using a sync group is more performant, and is recommended in any case where this knowledge is known ahead of time.

Setting Up Sync Groups

To create a sync group:

Swift
Kotlin
JS
Java
C#
C++
Rust