Pub/Sub pricing
Pub/Sub is priced on the number of unique users that interact with your application each month. Messages, channels and connection time don't affect your bill.
Ably prices on monthly active users (MAUs). A user who interacts with your application counts once in a calendar month, whichever products they use, however many messages they publish or receive, however many channels they attach to, and however long they stay connected.
Monthly active users
An MAU is a unique clientId that is active during a calendar month. A clientId becomes active when a realtime client created from the device package connects to Ably, or when an HTTP client created from the device package makes a request, such as publishing a message or querying history. It is counted once for that month, whether it was active for a minute or every day.
Each clientId is counted once per app. The same user counts once whether they connect from one device or several, and whether they use Pub/Sub alone or Pub/Sub alongside Chat, Spaces, AI Transport, LiveObjects or LiveSync in the same app.
Identifying users
Because an MAU is identified by their clientId, the way you assign them decides what you are billed for:
- Assign one
clientIdper user, and use it on every device and in every session. A user who connects from a phone and a laptop with differentclientIds counts as two MAUs. - Never share a
clientIdbetween users.
Anonymous users
Users who are anonymous to your application still require a clientId. Generate an identifier for each anonymous user and store it on their device, so that a returning anonymous user counts only once. If your application generates a fresh identifier on every visit, each visit counts as a new MAU.
Servers
Realtime and HTTP clients created from the server package are not counted as MAUs, however many connections they hold or requests they make, and they do not need to set a clientId.
If you call the REST API directly rather than through an SDK, declare the caller as a server. With API key authentication, add clientType=server as a request or connection parameter. With token authentication, add the x-ably-clientType claim with the value server to the JWT you issue to the server. A request that doesn't declare itself as a server is counted as a user.
Resource-based pricing
If your account is still on resource-based pricing, Pub/Sub is charged on what you use rather than on your number of MAUs: per million messages, per million channel minutes and per million connection minutes. How messages are counted lists which Pub/Sub operations generate messages.
To move your account to MAU pricing, follow the migration guide.
Resource efficiency
Regardless of whether you are on MAU pricing or resource-based pricing, effectively managing resources is beneficial to your application:
- Mark messages as ephemeral to exempt them from persistence, rewind, resume and integrations.
- Set
echoMessages: falseso that messages are not delivered back to the publisher. - Enable conflation to deliver only the latest message per key in each time window.
- Enable server-side batching to group messages into single deliveries that count as one message each.
- Enable delta compression to keep large, structurally similar messages within the 5KiB size that counts as a single message.
- Use occupancy instead of presence when you only need member counts, and enable server-side presence batching where you need member-level detail on large channels.
- Close connections and detach from channels when they are no longer needed to tidy up resources.