What is Sync?

A Slightly Opinionated Tour of the Space

We say that Zero is a sync engine. But what even is that? And why does it matter?

Problem

Let's say you have some data that you want to read and write from multiple devices. The most common way to do this today is to put that data into a central database and expose access to it via APIs.

Sharing data with APIs

Sharing data with APIs

This works, but has downsides:

  • Slow access. Every read and write has to go to the server, adding hundreds of milliseconds to each interaction.
  • Stale data. API responses are immediately stale. The client has no way to know when to refresh them. Users may make decisions based on old information, and the views on different devices diverge over time.
  • Online-only. If the server or the user's network connection is down, the app stops working completely.

Solution

Sync engines can solve these problems by keeping a local copy of the data on each device.

The app reads and writes only to the local copy, not to the network. The sync engine pushes changes back and forth between the local copy and the server in the background, when connectivity allows.

Sharing data with sync

Sharing data with sync

This architecture can enable:

  • Instant UI. Reads and writes are to local storage, effectively instant.
  • Realtime updates. By running the sync engine continuously, users can see updates from other devices and users in realtime. The data is always fresh.
  • Offline support. Because data is stored locally, it is possible to support at least limited offline access. For example, Zero supports read-only access while offline, and other sync engines support some limited offline writes.

Sync engines also simplify the development of complex apps. Big parts of modern app development are just data plumbing: fetching data, updating data, caching data, invalidating caches, keeping different copies of data consistent, and so-on. A sync engine abstracts all this away and lets you focus on what your app actually does.

History of Sync

Sync Engines have been around a long time.

The first mass-market sync engine was probably Lotus Notes, released way back in 1989! Since then, there has been a steady trickle of important software built on sync engines:

  • Microsoft Exchange (1996)
  • Google Docs (2006)
  • Dropbox (2007)
  • Superhuman (2017)
  • Figma (2016)
  • Linear (2019)

But sync engines are very hard to build. Typically, a new custom sync engine is built for each application at great expense. Knowledge about the specific application and its data model must be built into each sync engine to correctly handle conflicts and partial sync.

There have also been some attempts at general-purpose sync engines:

  • Firebase Realtime Database (2012) - a cloud-hosted database and that syncs.
  • PouchDB (2013) - a sync engine attachment for CouchDB.
  • Realm (2016) - a mobile database with sync capabilities.
  • Replicache (2020) - The predecessor to Zero, a JavaScript library for building collaborative applications with real-time sync.

But all have suffered from one or more significant problems that have prevented widespread adoption:

  • No support for fine-grained authorization
  • Limited support for partial sync – users have to sync all data, even if they only need a small subset
  • Required adoption of non-standard backend databases or data models
  • Limited ability to put custom business logic on read or write paths

We are building Zero to address these limitations, and bring the benefits of sync to many more applications.