Message Storage

Ably stores all messages for two minutes by default. This can be increased to 24 hours, or 72 hours depending on your account package. It is also possible to persist the last message sent to a channel for a year. Ably integrations can also be used to send messages outside of Ably for long-term storage.

The default message storage of two minutes enables clients that briefly disconnect from Ably to automatically retrieve any messages they may have missed. These messages can also be retrieved using the history feature, and this applies to both regular messages and presence messages.

The following diagram illustrates the default persistence of messages:

Default Persistence

If you need to retain messages for longer than the default two minutes you can enable persisted history by setting a channel rule. When persisted history is enabled for a channel any messages will be stored on disk for 24 or 72 hours depending on your account package.

Messages can be retrieved using the history feature. This is illustrated in the following diagram:

Persist All Messages

Note that every message that is persisted to, or retrieved from, disk counts as an extra message towards your monthly quota. For example, with persistence enabled a published message counts as two messages for your monthly quota. If the message is then retrieved another message will be deducted.

You can persist just the last message sent to a channel for one year by setting a channel rule. Note that this does not apply to presence messages.

Messages persisted for a year can only be retrieved using the rewind channel option. They cannot be retrieved using the history feature.

The following diagram illustrates persisting the last message sent on a channel:

Persist Last Message

Integrations provide the ability to store your messages outside of Ably, for example in your own database or data warehouse.

Set up an integration rule to send messages to your own systems using webhooks or serverless functions. Integration rules can additionally filter which messages sent to a channel should trigger these events.

Default message storage – two minutes