Time-to-Live for Messages

The time-to-live (TTL) for messages means that messages persist in the partitions of a stream topic for a specific time period. During that time, messages can be read or re-read by consumers. Once the TTL for a message expires, the message is marked for deletion.

Setting TTL for Message

Set the TTL for topic messages when you create or edit a stream. Because the TTL setting is specified at the stream-level, all messages in all topics associated with the stream will have the same TTL. The default TTL is 604,800 seconds (7 days).

Deleting Expired Messages

Expired messages are deleted by an automatic process that runs at periodic intervals of TTL/10 and no later than 24 hours. For example:

  • If the TTL is set to 24 hours, expired messages are deleted once every 24 hours.
  • If the TTL is set to 7 days (168 hours, which is the default), expired messages are deleted once every 24 hours because 24 is greater than 168/10.
  • If the TTL is set to 20 days (480 hours), expired messages are deleted once every 48 hours because 48 is greater than 24.
Attention: The automatic process deletes messages from active streams that have an expired TTL. The automatic process does not purge deleted messages with an expired TTL from idle streams until producer or consumer operations are performed on the streams.

Monitor disk space utilization and manually delete messages from streams, as needed, to reclaim disk space.

To manually delete expired messages, run the maprcli command stream purge.

For More Information