Time-based or size-based retention for replay data before a Pulsar rollback?
0 reputation · 28 Oct 2022, 21:27 UTC
0 reputation · 28 Oct 2022, 21:27 UTC
Consider a namespace on a Pulsar 3.x cluster where recent messages must stay replayable if a deployment is rolled back. Only persistent topics backed by BookKeeper ledgers qualify, and bookie SSD capacity is limited, so retention cannot grow without bound. Tiered storage offload is available but adds retrieval latency for offloaded ledgers.
Time-based retention holds a fixed window regardless of traffic, but a rollback after a quiet stretch can find that window already purged. Size-based retention bounds disk use directly, yet a traffic spike can evict messages before the intended replay horizon passes. Once offload is enabled, retention and offload thresholds interact, and offloader behavior during broker failover is operator-configured and varies across releases.
32275 reputation · 29 Oct 2022, 04:44 UTC
To guarantee a replay horizon under bursty traffic without exceeding bookie SSD budgets, use a hybrid retention policy: set a time-based retention window that matches your maximum rollback horizon, and a size-based cap that is calculated to accommodate peak traffic bursts for that same duration.
In Pulsar 3.x, the broker enforces the stricter of the two retention limits. If you rely solely on size-based retention, a traffic spike will evict older ledgers prematurely, breaking your replay horizon. If you rely solely on time-based retention, a spike can exhaust bookie SSDs.
Tiered storage offload solves this by moving data to cheaper storage before the retention policy deletes it. To keep data local (on SSDs) for the immediate rollback window, configure the offloadThreshold to be slightly larger than your expected rollback lag. This ensures ledgers remain in BookKeeper until the window closes, while the overall retention policy prevents the total dataset from growing indefinitely.
Peak Throughput × Window Duration).pulsar-admin namespaces set-retention / --size --time
pulsar-admin namespaces set-offload-threshold / --size
pulsar-admin topics list --include-offloaded
Offloader state is persisted in ZooKeeper. During a broker failover, the new broker owner resumes the offloading process based on the existing metadata. It will not prematurely offload ledgers that have not yet met the offloadThreshold. However, offloading may be delayed until the offloader component fully initializes on the new broker.
This guidance assumes Pulsar 3.x. Because offload behavior was refined in version 3.1.0, users on earlier 3.x releases should verify that offloadThreshold is being honored by monitoring ledger movement during a simulated burst.
Missing Diagnostic: What is the average ledger size (maxLedgerSize) for your topics? If ledgers are exceptionally large, they may be offloaded based on size thresholds before the time-based rollback window has elapsed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.