Sync hour usage best practices

Hi all,

I am just starting out with flexible sync, which works great, but I noticed the sync runtime hours are starting to increase rapidly, for only a couple of syncs I did, even when adding just 2 records on the device and not doing anything else, the sync session seems to remain open. I was wondering whether this is to be expected or whether my set-up is incorrect/suboptimal, I used the initial subscriptions to get all data and used rules to define security so only users’ own records are returned;

<RealmProvider
            schema={[ObjectOne, ObjectTwo, ObjectThree, ObjectFour]}
            schemaVersion={2}
            {... !isAnonUser && {
                sync: {
                    flexible: true,
                    newRealmFileBehavior: {
                        type: OpenRealmBehaviorType.DownloadBeforeOpen,
                    },
                    existingRealmFileBehavior: {
                        type: OpenRealmBehaviorType.OpenImmediately,
                    },
                    initialSubscriptions: {
                        update: (mutableSubs, realm) => {
                            mutableSubs.add(realm.objects(ObjectOne))
                            mutableSubs.add(realm.objects(ObjectTwo))
                            mutableSubs.add(realm.objects(ObjectThree))
                            mutableSubs.add(realm.objects(ObjectFour))
                        }
                    },
                    onError: (e) => {
                        console.log(e);
                    }
                }
            }}
        >
            {children}
        </RealmProvider>

Thanks!

This is expected, and shouldn’t be a cause for concern - “sync time” accounts for the amount of time that a client is actively connected, even while that connection is actually idle.
The sync session remains open/active so that it can listen for real-time changes to the data in the subscription.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.