You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
meta_description: "Understand how Chat SDK features contribute to your message count, including messages, typing indicators, reactions, and cost optimization strategies."
intro: "How Chat SDK features contribute to your message count and strategies to optimize costs."
6
+
redirect_from:
7
+
- /docs/chat/message-billing
8
+
---
9
+
10
+
The [Chat SDK](/docs/chat) is built on top of [Pub/Sub](/docs/pub-sub). All Chat operations generate Pub/Sub messages that follow the same billing rules.
11
+
12
+
<Asidedata-type="further-reading">
13
+
For the complete reference on how all Ably operations count as messages, see [message billing](/docs/platform/pricing/message-billing). For package comparison and volume discounts, see the [pricing](https://ably.com/pricing) page.
14
+
</Aside>
15
+
16
+
## What counts as a message <aid="messages"/>
17
+
18
+
Each Chat feature generates Pub/Sub messages. For example, 1 message sent in a room with 50 subscribers counts as **51 messages** (1 inbound + 50 outbound). Typing indicators are the most significant cost driver. In a room with 50 subscribers, one active typer generates approximately **306 messages per minute** from heartbeat events alone, plus a stop event.
19
+
20
+
For the complete breakdown of how each Chat operation counts as messages, see the [Chat operations](/docs/platform/pricing/message-billing#chat-operations) table in the central message billing reference.
21
+
22
+
## Channels and connection minutes <aid="channels-connections"/>
23
+
24
+
Chat rooms map directly to Pub/Sub channels. Each room feature (messages, typing, reactions, presence, occupancy) uses underlying Pub/Sub channels. Ably bills each connected client for [connection minutes](/docs/platform/pricing#connections) in the same way as Pub/Sub.
meta_description: "Understand how different Ably Pub/Sub operations contribute to your message count, including persistence, presence, and cost optimization strategies."
meta_description: "Understand how operations across all Ably products contribute to your message count, including Pub/Sub, Chat, LiveObjects, and Annotations."
intro: "How operations across all Ably products contribute to your message count."
5
6
---
6
7
7
-
This page explains how different Ably operations contribute to your message count. Understanding message billing helps you optimize costs and choose the right features for your use case.
8
+
All Ably products count messages for billing purposes. The following sections explain how operations across Pub/Sub, Chat, LiveObjects, and Annotations contribute to your message count.
8
9
9
10
<Asidedata-type="further-reading">
10
11
For package comparison and volume discounts, see the [pricing](https://ably.com/pricing) page. For general billing information, see [billing](/docs/platform/pricing/billing).
11
12
</Aside>
12
13
13
-
## Basic message counting <aid="basic-counting"/>
14
+
## How messages are counted <aid="basic-counting"/>
14
15
15
-
Every message sent through Ably is counted for both publishing and delivery:
16
+
Ably counts every message for both publishing and delivery:
16
17
17
18
* 1 publish = 1 inbound message
18
19
* Each subscriber delivery = 1 outbound message per subscriber
19
20
* Each integration delivery = 1 outbound message per [integration](/docs/platform/integrations) target
20
21
* Messages from metachannels (such as `[meta]log` and `[meta]stats`) follow the same counting rules
21
22
22
-
For example, 1 publisher sends a message to a channel with 10 subscribers =**11 messages** (1 inbound + 10 outbound).
23
+
For example, if 1 publisher sends a message to a channel with 10 subscribers, this counts as**11 messages** (1 inbound + 10 outbound).
23
24
24
25
## Message size <aid="message-size"/>
25
26
26
-
Message size for Pub/Sub messages is calculated as the sum of the `name`, `clientId`, `data`, and `extras`[properties](/docs/api/realtime-sdk/messages#properties) before any compression or expansion occurs in the serialization process.
27
-
28
-
<Asidedata-type="note">
29
-
LiveObjects and Annotations have different billing considerations. See [LiveObjects billing](/docs/liveobjects/concepts/billing) and [Annotations](/docs/messages/annotations) for details on their respective billing.
30
-
</Aside>
27
+
Ably calculates message size for Pub/Sub messages as the sum of the `name`, `clientId`, `data`, and `extras`[properties](/docs/api/realtime-sdk/messages#properties) before any compression or expansion occurs in the serialization process.
31
28
32
29
*`name` and `clientId` are calculated as the size in bytes of their UTF-8 representation.
33
30
*`data` is calculated as the size in bytes if it is binary, or its UTF-8 byte length if it is a string.
34
31
*`extras` is calculated as the string length of its JSON representation.
35
32
36
-
The [bandwidth](/docs/platform/pricing#bandwidth) allowance calculation uses an average message size of 5KiB. If your total bandwidth for the month exceeds this baseline, the overage is charged per GiB.
33
+
The [bandwidth](/docs/platform/pricing#bandwidth) allowance calculation uses an average message size of 5KiB. If your total bandwidth for the month exceeds this baseline, Ably charges overage per GiB.
37
34
38
35
See [maximum message size](/docs/platform/pricing/limits#message) for the size limits per package type.
39
36
40
-
## Operations and their billing impact <aid="operations"/>
37
+
## Pub/Sub operations <aid="pubsub-operations"/>
41
38
42
-
The following table shows how different operations contribute to your message count:
39
+
The following table shows how Pub/Sub operations contribute to your message count:
43
40
44
41
| Operation | Messages counted | Notes |
45
42
| --- | --- | --- |
@@ -51,21 +48,51 @@ The following table shows how different operations contribute to your message co
51
48
| Rewind on attach | Rewound messages count as outbound | Up to 100 messages per [rewind](/docs/channels/options/rewind)|
52
49
| Push notification | Counted separately per push platform | See [push notifications](/docs/push)|
53
50
51
+
For Pub/Sub-specific cost optimization strategies, see [Pub/Sub pricing](/docs/pub-sub/pricing).
52
+
53
+
## Chat operations <aid="chat-operations"/>
54
+
55
+
The [Chat SDK](/docs/chat) is built on top of [Pub/Sub](/docs/pub-sub). All Chat operations generate Pub/Sub messages that follow the same counting rules.
56
+
57
+
| Operation | Messages counted | Notes |
58
+
| --- | --- | --- |
59
+
| Chat message | 1 inbound + 1 per subscriber outbound | Same as a standard publish |
60
+
| Typing indicator heartbeat | 1 inbound + 1 per subscriber outbound | Default interval is 10 seconds; approximately 6 events per minute per active typer |
61
+
| Typing indicator stop | 1 inbound + 1 per subscriber outbound | Sent when a user stops typing |
62
+
| Room reaction | 1 inbound + 1 per subscriber outbound | Same as a standard publish |
63
+
| Presence enter/leave/update | 1 inbound + 1 per presence subscriber outbound | Same as Pub/Sub presence |
LiveObjects has a different billing scheme based on ObjectMessages. Each ObjectMessage counts as:
71
+
72
+
* 1 outbound message per connected client (delivery)
73
+
* 1 inbound message per connected client (acknowledgment)
74
+
75
+
See the [LiveObjects billing](/docs/liveobjects/concepts/billing) page for details.
76
+
77
+
## Annotations <aid="annotations"/>
78
+
79
+
[Annotations](/docs/messages/annotations) have a different billing scheme from standard messages. See the [Annotations](/docs/messages/annotations) page for details on how annotation operations are counted.
80
+
54
81
## Persistence billing <aid="persistence"/>
55
82
56
-
When persistence is enabled via [channel rules](/docs/storage-history/storage), each message stored to disk counts as an additional message.
83
+
When persistence is enabled via [channel rules](/docs/storage-history/storage), Ably counts each message stored to disk as an additional message.
57
84
58
-
If you persist all messages, a message published to 10 subscribers with persistence enabled = 1 (publish) + 10 (subscriber delivery) + 1 (persistence storage) = **12 messages**.
85
+
If you persist all messages, a message published to 10 subscribers with persistence enabled counts as 1 (publish) + 10 (subscriber delivery) + 1 (persistence storage) = **12 messages**.
59
86
60
-
If you persist last message only, the most recent message is stored. The storage cost is 1 additional message per new "last message" stored.
87
+
If you persist the last message only, Ably stores the most recent message. The storage cost is 1 additional message per new "last message" stored.
61
88
62
89
Retrieving persisted messages via the [history API](/docs/storage-history/history) also counts: each message returned in a history response = 1 additional message.
63
90
64
91
To avoid additional costs for messages that do not need persistence, history, rewind, integrations, or resume, mark them as [ephemeral](/docs/pub-sub/advanced#ephemeral). Ephemeral messages are exempt from all of these features, reducing your billable message count.
65
92
66
93
## Presence event billing <aid="presence"/>
67
94
68
-
Presence events (enter, leave, update) are billed as regular messages:
95
+
Ably bills presence events (enter, leave, update) as regular messages:
69
96
70
97
* 1 presence enter event with 100 presence subscribers = **101 messages** (1 enter + 100 deliveries)
71
98
@@ -79,19 +106,6 @@ To reduce presence costs:
79
106
* Enable [server-side batching](/docs/presence-occupancy/presence#large-presence) to group presence events and support up to 20,000 members per channel.
80
107
* Subscribe to presence updates only on channels where you need member-level detail.
The following table summarizes strategies for reducing message costs:
85
-
86
-
| Strategy | How it reduces costs | When to use |
87
-
| --- | --- | --- |
88
-
|[Ephemeral messages](/docs/pub-sub/advanced#ephemeral)| Exempt from persistence, rewind, resume, and integrations | Streaming data where history is not needed |
89
-
|[echoMessages: false](/docs/pub-sub/advanced#echo)| Prevents self-delivery to the publisher | Optimistic UI patterns and server-side publishers |
90
-
|[Conflation](/docs/guides/pub-sub/data-streaming#solution-message-conflation)| Delivers only the latest message per key in each time window | High-frequency updates where only the latest value matters |
91
-
|[Server-side batching](/docs/guides/pub-sub/data-streaming#solution-server-side-batching)| Groups messages into single deliveries | High-throughput channels where slight delay is acceptable |
|[Occupancy](/docs/presence-occupancy/occupancy) instead of presence | Avoids n-squared presence event fan-out | When you need member counts, not individual identities |
94
-
95
109
<Asidedata-type="further-reading">
96
110
See the [pricing](https://ably.com/pricing) page for package comparison and volume discounts.
meta_description: "Understand how Pub/Sub operations contribute to your message count, including persistence, presence, and cost optimization strategies."
intro: "How Pub/Sub operations contribute to your message count and strategies to optimize costs."
6
+
redirect_from:
7
+
- /docs/pub-sub/message-billing
8
+
---
9
+
10
+
Pub/Sub operations contribute to your message count based on publishing, delivery, and optional features like persistence and presence. The following sections explain how Ably counts these operations and how to optimize costs.
11
+
12
+
<Asidedata-type="further-reading">
13
+
For the complete reference on how all Ably operations count as messages, see [message billing](/docs/platform/pricing/message-billing). For package comparison and volume discounts, see the [pricing](https://ably.com/pricing) page.
14
+
</Aside>
15
+
16
+
## What counts as a message <aid="messages"/>
17
+
18
+
Every message published through Pub/Sub counts as 1 inbound message, with each subscriber delivery counting as 1 outbound message. Optional features like persistence, history retrieval, and integrations generate additional messages.
19
+
20
+
For the complete breakdown of how each Pub/Sub operation counts as messages, see the [Pub/Sub operations](/docs/platform/pricing/message-billing#pubsub-operations) table in the central message billing reference.
21
+
22
+
## Channels and connection minutes <aid="channels-connections"/>
23
+
24
+
[Channels](/docs/channels) are the unit of message distribution. Each channel you use contributes to your [channel count](/docs/platform/pricing#channels). Ably bills [connection minutes](/docs/platform/pricing#connections) per minute of connection time for each connected client.
The following table summarizes strategies for reducing message costs:
29
+
30
+
| Strategy | How it reduces costs | When to use |
31
+
| --- | --- | --- |
32
+
|[Ephemeral messages](/docs/pub-sub/advanced#ephemeral)| Exempt from persistence, rewind, resume, and integrations | Streaming data where history is not needed |
33
+
|[echoMessages: false](/docs/pub-sub/advanced#echo)| Prevents self-delivery to the publisher | Optimistic UI patterns and server-side publishers |
34
+
|[Conflation](/docs/guides/pub-sub/data-streaming#solution-message-conflation)| Delivers only the latest message per key in each time window | High-frequency updates where only the latest value matters |
35
+
|[Server-side batching](/docs/guides/pub-sub/data-streaming#solution-server-side-batching)| Groups messages into single deliveries | High-throughput channels where slight delay is acceptable |
|[Occupancy](/docs/presence-occupancy/occupancy) instead of presence | Avoids n-squared presence event fan-out | When you need member counts, not individual identities |
38
+
39
+
<Asidedata-type="further-reading">
40
+
For the full list of message counting rules across all products, see [message billing](/docs/platform/pricing/message-billing).
0 commit comments