What is LiveSync?

LiveSync enables you to synchronize changes in your database to frontend clients at scale. LiveSync is database agnostic but currently only supports PostgreSQL in its early access version. It uses Ably’s global message delivery network to sync user data in realtime.

LiveSync is made up of two key components:

Database Connector
a backend service for broadcasting changes from your database in realtime.
Models SDK
a frontend library that simplifies subscribing to changes in data models and applying optimistic updates, merging them with confirmed updates.

The following diagram provides a simplified overview of the LiveSync solution:

What is LiveSync

The Database Connector uses the outbox pattern to broadcast application-specific change events from your database to frontend clients via Ably channels.

When you update the data in your database, you record a change event transactionally in a dedicated outbox table. The outbox changes are detected by the Database Connector, which then publishes them as messages on channels. Using the Models SDK, your client applications subscribe to these change events and update their local state with the new data.

The Models SDK enables you to easily create live and observable data models in your frontend applications, ensuring they remain synchronized with your database’s state in realtime. By subscribing to a model, you receive the changes made by other users, enabling the creation of a seamless, multiplayer application experience.

The Models SDK works as follows:

Sync
bootstraps the client state during the initial page load.
Merge
updates the client state in response to realtime change events.
Optimistic updates
provides instantaneous feedback to the user when they change the data.
Subscribe
renders changes to the model state in your application in realtime.

The Models SDK is built on Ably’s JavaScript SDK and can be easily integrated into any front-end framework. The key advantages include:

  • The Ably JavaScript SDK enables you to extend your application’s functionality with Pub/Sub Channels.

LiveSync is currently in the early release stage, primarily intended for experimental use and not yet suitable for production environments. Your feedback will help in prioritizing improvements and fixes in subsequent releases.

Database Connector