Principles and "good to know"

The following are principles that are good to understand when working with Synced Realms:

  • The server using a per-Realm transaction history log file to allow correct integration of changesets irrespective of the order or time when the client sends the changesets.

  • The default time-to-live for the transaction history is 30 days. E.g. clients will have to connect at least once within that timeframe to ensure that changes are reflected. Outside of this time-frame the client will receive the most recent state from the server (“Client Reset”)

  • When writing objects on the client it’s best to only update actual changed parts of an object - otherwise all elements of a object will be communicated via the changeset, integrated, and then replicated out to all clients. Thus we recommend using the help options (.copyToRealmOrUpdate flag)

  • Query Based Sync is convenient, though do not confuse this with a typical REST type request. A query based sync creates a persistent subscription based on the search query and will create a live object based on that subscription. As such it is not meant to be for ephemeral requests. Thus manage subscriptions as you would any allocated resource by closing subscriptions once not required anymore.

  • Integrating changesets incurs processing and computational overhead. Thus the more independent Realms are used the higher it can scale. In many use-cases this is easily achievable by using concepts such as: Per user, per region Realms. Separating “read-from-client” per-user realms vs. “update-all-from-server” shared realm