Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/pages/docs/livesync/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ LiveSync is a powerful realtime data synchronization product designed to facilit

LiveSync can be used in applications where your database is the source of truth for the application state, and that state needs to be reflected in realtime to client applications. LiveSync enables this data synchronisation while maintaining data integrity and low latency.

<Aside data-type='see-evidence'>If a client reconnects within two minutes, full connection recovery with exactly-once delivery is guaranteed. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/idempotency#connection-recovery-and-exactly-once-delivery)</Aside>

![What is LiveSync](../../../images/content/diagrams/what-is-livesync.png)

By using Ably Pub/Sub [channels](https://ably.com/solutions/channels) and [SDKs](/docs/sdks), clients subscribing to messages published by a LiveSync database connector benefit from features like [connection-recovery](/docs/connect/states), [exactly-once delivery](/docs/platform/architecture) and [ordering guarantees](https://faqs.ably.com/reliable-message-ordering-for-connected-clients) out of the box. Ably's platform guarantees and [four pillars of dependability](https://ably.com/four-pillars-of-dependability) apply by default.
Expand All @@ -17,6 +19,8 @@ By using Ably Pub/Sub [channels](https://ably.com/solutions/channels) and [SDKs]

Ably's [pub/sub channels](/docs/channels) are the mechanism used by LiveSync for synchronizing data updates across clients. When a message is published on a channel by the database connector, it is immediately broadcast to all subscribers of that channel.

<Aside data-type='see-evidence'>Messages published using Realtime have consistent ordering for all subscribers, with each message assigned a unique serial number to preserve its place. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/message-ordering)</Aside>

## Hosted database connectors <a id="hosted"/>

Take advantage of the Ably hosted database connectors to automatically publish changes from your database as messages on Ably channels. The hosted database connectors support controlling which events are routed to which channels, and using Ably's [Auth](/docs/auth) and [Capabilities](/docs/auth/capabilities) you can control which channels a client is allowed to access.
Expand All @@ -29,6 +33,8 @@ Ably provides hosted connectors for:

LiveSync can benefit a wide range of applications where it's important to broadcast database changes in realtime to keep clients in sync, including: Customer Relationship Management (CRM) applications, customer support applications, productivity or task management applications, online auctions, collaborative form editing, e-commerce systems, chat conversations, multiplayer turn-based games and realtime newsfeeds.

<Aside data-type='see-evidence'>With 50% capacity headroom built in, Ably instantly absorbs traffic spikes without degradation or pre-provisioning. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/infrastructure-operations#resource-implications)</Aside>

## Pricing <a id="pricing"/>

LiveSync [pricing](https://ably.com/pricing) is mainly based on message consumption (alongside concurrent connections and concurrent channels). This means that each update published from the database connector to Ably channels is counted as a single message. The message is received by every client subscribed to that channel, each of which counts as one additional message. If, for example, one update is published by the database connector and there are three clients subscribed, that one update will result in four messages in total.
6 changes: 6 additions & 0 deletions src/pages/docs/livesync/mongodb/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ The MongoDB database connector utilizes the MongoDB [change streams](https://www

By using Ably Pub/Sub channels and SDKs, clients subscribing to messages published by the MongoDB database connector benefit from features like [connection-recovery](/docs/connect/states), [exactly-once delivery](/docs/achieving-exactly-once-message-processing-with-ably) and [ordering guarantees](https://faqs.ably.com/reliable-message-ordering-for-connected-clients) out of the box.

<Aside data-type='see-evidence'>Failed connections automatically try up to 5 alternative endpoints worldwide, maximizing reconnection success. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/edge-network)</Aside>

![What is MongoDB database connector](../../../../images/content/diagrams/ably-connector-for-mongodb.png)

## How it works <a id="how-it-works"/>

The MongoDB database connector is enabled through an Ably integration rule. The rule will consume document changes from your MongoDB deployment via the MongoDB [Change Streams API](https://www.mongodb.com/docs/manual/changeStreams/). The integration rule exists as a "database connector" component that is entirely provisioned and managed by Ably and is fault-tolerant with automatic fail-over.

<Aside data-type='see-evidence'>Ably delivers messages globally with a median latency of 37ms, validated by over 6 million daily measurements across its infrastructure. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/latency#latency)</Aside>

When a change event is received over the Change Streams API it is published to an Ably channel. When you configure the integration rule, you can specify how change events are mapped to individual Ably channels. Clients can then subscribe to database changes by subscribing to Ably channels. Ably [Auth](/docs/auth) and [Capabilities](/docs/auth/capabilities) control which channels a client can interact with.

## Integration rule <a id="integration-rule"/>
Expand Down Expand Up @@ -153,6 +157,8 @@ For the schema and fields available on a change event, see the [MongoDB Change E
You must set the `_ablyChannel` field on the root of the change event. This allows the MongoDB database connector to know where to route the change event.
</Aside>

<Aside data-type='see-evidence'>Ably's infrastructure serves billions of devices each month, handling enterprise-scale traffic reliably and quickly. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/scalability)</Aside>


### Dynamically route change events <a id="channel-routing"/>

Expand Down
4 changes: 4 additions & 0 deletions src/pages/docs/livesync/postgres/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ When your backend server processes a request to update data in your database, it

By using the outbox table, you can specify which channel that record should be published to, and make changes to your other database tables transactionally with the publish. This mitigates the problem of trying to transactionally write to two different systems; Ably and the database. You can gain exactly-once and in-order delivery over Ably transactionally with other data you modify in your database.

<Aside data-type='see-evidence'>In catastrophic datacenter failures, Ably automatically reroutes all traffic in under 2 minutes, maintaining service continuity. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/edge-network)</Aside>

The Postgres database connector automatically retries failed publishes while maintaining ordering of messages on each channel.

<Aside data-type='see-evidence'>Ably's SDKs automatically resolve edge network failures within 30 seconds, keeping your users connected even during infrastructure issues. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/edge-network)</Aside>

The database connector can be [self-hosted](#self-host).

## Integration rule <a id="integration-rule"/>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/docs/livesync/postgres/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ When creating a new `model` using the Models SDK you provide two functions to th
- the [`sync()`](#sync) function is used by the SDK to retrieve the current state of the `model` from your backend,
- the [`merge()`](#merge) function is used by the SDK to merge state change events published by the Postgres database connector with the existing frontend state in the `model`.

<Aside data-type='see-evidence'>Applications maintain their state during disruptions - all messages are received in correct order with zero message loss. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/connection-recovery)</Aside>

The following diagram provides a simplified overview of the Models SDK:

![A flow diagram showing how all of the livesync models components tie in together](../../../../images/content/diagrams/livesync-models-components.png)
Expand Down Expand Up @@ -116,6 +118,8 @@ const model = modelsClient.models.get({
```
</Code>

<Aside data-type='see-evidence'>Ably's tiered fanout architecture allows it to scale to handle millions of subscribers per channel. [Click here for evidence 🔬](https://ably.com/docs/platform/architecture/platform-scalability#handling-high-scale-fanout)</Aside>

## Sync function <a id="sync"/>

The sync function is used by the Models SDK to fetch the latest data from your backend. The SDK will automatically call this function when it is initialized, and when the SDK detects that the latest data is no longer available on the Ably channel.
Expand Down