Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/pages/docs/channels/options/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ Occupancy events have a payload in the `data` property with a value of `occupanc

### Inband Objects <a id="objects"/>

[Inband objects](/docs/liveobjects/inband-objects) allows clients to subscribe to changes to [LiveObjects](/docs/liveobjects) channel objects as regular channel messages.
[Inband objects](/docs/liveobjects/inband-objects) allows clients to subscribe to changes to [LiveObjects](/docs/liveobjects) channel objects as regular channel messages. Set the `objects` channel parameter to `'objects'` to stream the full state, or `'notification'` to receive change notifications.

When using inband objects, the client receives messages with the special name `[meta]objects` that describe the current set of objects on a channel.

Expand Down
4 changes: 2 additions & 2 deletions src/pages/docs/liveobjects/concepts/billing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ await myObject.get('visits').batch((ctx) => {

## Synchronization <a id="synchronization"/>

During initial synchronization and resynchronization, each object on the channel is sent as a message.
During initial synchronization and resynchronization, each object on the channel is sent as one or more messages. Large objects, such as maps with many entries, may be split across multiple messages.

For example, if a channel contains 10 objects (such as `LiveMap` and `LiveCounter` instances), a client attaching to the channel will receive 10 messages during synchronization.
For example, if a channel contains 10 objects (such as `LiveMap` and `LiveCounter` instances), a client attaching to the channel will receive at least 10 messages during synchronization.

Similarly, if a client becomes disconnected and needs to resynchronize, it will receive messages for each object that needs to be synchronized.

Expand Down
2 changes: 1 addition & 1 deletion src/pages/docs/liveobjects/concepts/synchronization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ When a channel first becomes active in a region, the channel loads the object da

While Ably maintains the source of truth on the channel, each connected client keeps a local representation of the objects on the channel.

When the client first attaches to the channel, the state of the channel objects is streamed to the client. [Lifecycle events](/docs/liveobjects/lifecycle#synchronization) allow your application to be notified when the local state is being synchronized with the Ably service.
When the client first attaches to the channel, the state of the channel objects is streamed to the client. Large objects, such as maps with many entries, may be delivered across multiple messages during synchronization. [Lifecycle events](/docs/liveobjects/lifecycle#synchronization) allow your application to be notified when the local state is being synchronized with the Ably service.

<If lang="javascript">
<Aside data-type='note'>
Expand Down
75 changes: 65 additions & 10 deletions src/pages/docs/liveobjects/inband-objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,28 @@ If you're using LiveObjects from one of the the following languages, then use th
* [Java](/docs/liveobjects/quickstart/java)
</Aside>

Inband objects works by delivering changes to channel objects as regular channel messages, similar to [inband occupancy](/docs/channels/options#occupancy).
Inband objects works by delivering changes to channel objects as regular channel messages, similar to [inband occupancy](/docs/channels/options#occupancy). Two modes are available:

* `objects` streams the full state of channel objects as a sequence of messages on attach and whenever the state changes.
* `notification` sends a lightweight notification whenever the state changes, with a link to retrieve the full state via the [REST API](/docs/liveobjects/rest-api-usage).

<Aside data-type='usp'>
Scalable message fanout

Inband object updates are delivered as regular channel messages through Ably's [horizontally scalable architecture](/docs/platform/architecture/platform-scalability), so LiveObjects state changes can be distributed to any number of subscribers simultaneously.
</Aside>

## Enable Inband Objects <a id="inband-objects-enable"/>
<Aside data-type='important'>
Clients require the `channel-metadata` [capability](/docs/auth/capabilities) to receive inband objects updates.
</Aside>

## Objects mode <a id="objects-mode"/>

The `objects` mode streams the full state of channel objects to the client. On attach, the client receives a sequence of `[meta]objects` messages describing the complete set of objects on the channel. When objects are updated, the client receives additional messages with the updated state.

To enable inband objects, use the `objects` [channel parameter](/docs/channels/options#objects) when getting a channel:
### Enable objects mode <a id="inband-objects-enable"/>

Enable `objects` mode using the `objects` [channel parameter](/docs/channels/options#objects) when getting a channel:

<Code>
```javascript
Expand All @@ -58,13 +69,9 @@ await channel.setOptions({ params: { objects: 'objects' } });
```
</Code>

<Aside data-type='important'>
Clients require the `channel-metadata` [capability](/docs/auth/capabilities) to receive inband objects updates.
</Aside>

## Subscribe to updates <a id="inband-objects-subscribe"/>
### Subscribe to updates <a id="inband-objects-subscribe"/>

When using inband objects, the client will receive special `[meta]objects` messages whenever the objects on the channel are updated. These messages provide a snapshot of the current set of objects on the channel.
The client receives `[meta]objects` messages whenever the objects on the channel are updated. These messages provide a snapshot of the current set of objects on the channel.

<Aside data-type='note'>
If there is a high rate of updates to the channel objects the inband messages are throttled. However, the client is guaranteed to receive a sequence of inband messages after the last change occurs so that the latest data is always available.
Expand All @@ -82,7 +89,7 @@ channel.subscribe('[meta]objects', (message) => {
```
</Code>

## Message Format <a id="inband-objects-message-format"/>
### Message format <a id="inband-objects-message-format"/>

Inband objects messages are sent as a sequence of messages, where each message contains a snapshot of a single object on the channel. Taken together, a set of messages belonging to the same sequence describes the complete set of objects on the channel.

Expand All @@ -97,3 +104,51 @@ The message `data` is a JSON object with the following top-level properties:
| `object` | A JSON representation of the object included in the message. |

The shape of the `object` is the same as the response format of an object when listing them via the [REST API](/docs/liveobjects/rest-api-usage#fetching-objects-list-values).

## Notification mode <a id="notification-mode"/>

The `notification` mode sends a `[meta]objects` message whenever the channel objects are updated. The message contains a link to retrieve the current state via the [REST API](/docs/liveobjects/rest-api-usage) rather than the full object state.

Unlike `objects` mode, the client does not receive the initial state on attach. The first `[meta]objects` message is sent when the state changes.

<Aside data-type='note'>
Use notification mode when individual objects on the channel may exceed the 64 KiB [message size limit](/docs/liveobjects/storage#operation-size).
</Aside>

### Enable notification mode <a id="notification-enable"/>

Enable notification mode using the `objects` [channel parameter](/docs/channels/options#objects) with a value of `'notification'`:

<Code>
```javascript
const channelOpts = { params: { objects: 'notification' } };
const channel = realtime.channels.get('my-channel', channelOpts);
```
</Code>

### Subscribe to notifications <a id="notification-subscribe"/>

Subscribe to `[meta]objects` messages to receive notifications when channel objects are updated:

<Code>
```javascript
channel.subscribe('[meta]objects', (message) => {
const { link } = message.data;
console.log("Objects updated, retrieve state from:", link);
});
```
</Code>

<Aside data-type='note'>
If there is a high rate of updates to the channel objects, notification messages are throttled after the first one. The client is guaranteed to receive a notification after the last change occurs.
</Aside>

### Notification message format <a id="notification-message-format"/>

Each notification message has a message `name` of `[meta]objects`.

The message `data` is a JSON object with the following property:

| Property | Description |
| -------- | ----------- |
| `link` | A relative URL path to retrieve the current channel objects via the [REST API](/docs/liveobjects/rest-api-usage#fetching-objects). For example, `/channels/{channelName}/object`. |
2 changes: 1 addition & 1 deletion src/pages/docs/liveobjects/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ For details on how using LiveObjects contributes to your billable usage, see [Bi

When using the realtime client libraries, LiveObjects usage is billed as follows:

* [State synchronization](/docs/liveobjects/concepts/synchronization#client-objects): On first attachment to a channel, or during resynchronization after a loss of continuity, the full state of channel objects is streamed to the client as [object messages](/docs/metadata-stats/stats#messages). Each object message received is counted as one message. Ably streams objects with a [tombstone](/docs/liveobjects/concepts/objects#tombstones) to maintain state consistency but these objects are not included in billing counts.
* [State synchronization](/docs/liveobjects/concepts/synchronization#client-objects): On first attachment to a channel, or during resynchronization after a loss of continuity, the full state of channel objects is streamed to the client as [object messages](/docs/metadata-stats/stats#messages). Each object message received is counted as one message. Large objects may be streamed across multiple object messages, each counted individually. Ably streams objects with a [tombstone](/docs/liveobjects/concepts/objects#tombstones) to maintain state consistency but these objects are not included in billing counts.
* [Object operations](/docs/liveobjects/concepts/operations): Creating or updating an object generates an _operation_, which is sent as an object message on the channel and billed accordingly. For example, if a user increments a counter, one object message is sent. If 10 clients subscribed to object messages receive it, that counts as 11 messages in total. Any client attached to a channel with `object-subscribe` capability is subscribed to all object messages on that channel.
* [Batch operations](/docs/liveobjects/batch): Multiple operations grouped into a batch are sent as a single object message and billed as one.

Expand Down
10 changes: 8 additions & 2 deletions src/pages/docs/liveobjects/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ Short disconnections (under two minutes) are resolved by replaying missed operat

## Object size limit <a id="limits"/>

The channel object has a maximum size limit, the default is 6.5(MB). This takes into account the size of every LiveObject (Map and Counter). When calculating the size of a channel object, Ably ignores any object or map entry with a [tombstone](/docs/liveobjects/concepts/objects#tombstones).
All objects on a channel share an aggregate size limit, which defaults to 6.5 MB. This is the combined size of every `LiveMap` and `LiveCounter` on the channel. There is no limit on the number of individual objects. When calculating the aggregate size, Ably excludes any object or map entry with a [tombstone](/docs/liveobjects/concepts/objects#tombstones), as well as any [unreachable](/docs/liveobjects/concepts/objects#reachability) objects.

<Aside data-type='note'>
If you're interested storing a larger amount of data on a channel, please [get in touch](https://ably.com/support) with your requirements.
If you're interested in storing a larger amount of data on a channel, please [get in touch](https://ably.com/support) with your requirements.
</Aside>

### Operation size <a id="operation-size"/>

Operations are limited by the message size limit of 64 KiB. This means that you cannot initialize an object with data larger than 64 KiB in a single operation. However, an object can grow beyond this size through incremental updates, for example by using a series of `set` operations on a `LiveMap`.

### Size calculation <a id="size-calculation"/>

A `LiveCounter` is a double-precision floating-point number and has a size of 8 bytes.

The size of a `LiveMap` object is calculated as the sum of the length of all keys plus the size of all values where:
Expand Down
2 changes: 1 addition & 1 deletion src/pages/docs/platform/pricing/limits.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Therefore, to provide the realtime platform-as-a-service economically to all cus
| **Message publish rate per channel (per second)**<p>*the maximum rate at which messages can be published for each channel*</p> | 50 | 50 | 50 | 50 |
| **Presence members per channel**<p>*the maximum number of clients that can be simultaneously present on a channel*</p> | 200 | 200 | 200 | 200 |
| **Presence members per channel with [server-side batching](/docs/messages/batch#server-side) enabled**<p>*the maximum number of clients that can be simultaneously present on a channel when server-side batching is enabled*</p> | 200 | 5,000 | 10,000 | 20,000 |
| **Total object size per channel(MB)**<p>*the maximum size of a channel object*</p> | 6.5 | 6.5 | 6.5 | 6.5 |
| **Total object size per channel(MB)**<p>*the maximum aggregate size of all objects on a channel*</p> | 6.5 | 6.5 | 6.5 | 6.5 |



Expand Down
Loading