Message Storage

Ably stores all messages for two minutes by default. This can be increased up to a year, or longer, 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. The time that messages will be stored for depends on your account package:

Package Minimum Maximum
Free 24 hours 24 hours
PAYG 72 hours 365 days
Enterprise 72 hours Custom

There is a cost associated with storing messages for longer than the minimum time period. Contact us to discuss enabling long term storage.

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 be retrieved using the rewind channel option, or from the REST history API using certain parameters.

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