[Enhancement] Optimize delayed message delivery by reducing unnecessary reads to storage in InMemoryDelayedDeliveryTracker #23912
Labels
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Search before asking
Motivation
In the current delayed message delivery, there's an opportunity to reduce unnecessary reads to storage.
In Pulsar, there are 2 implementations for the delayed delivery tracker, InMemoryDelayedDeliveryTracker and BucketDelayedDeliveryTracker.
This is configured by the
delayedDeliveryTrackerFactoryClassName
configuration key. The default setting chooses the in memory implementation:pulsar/conf/broker.conf
Lines 614 to 617 in b02d52c
The BucketDelayedDeliveryTracker contains an optimization to skip messages in reading which have been "indexed":
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
Lines 446 to 457 in 11a615e
This already reduces reads when BucketDelayedDeliveryTracker is in use.
The state of the InMemoryDelayedDeliveryTracker gets cleared after all consumers have disconnected:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
Lines 187 to 202 in 12b0579
Solution
It would be useful to keep state also in the InMemoryDelayedDeliveryTracker and skip reading delayed messages when the information is already available for the delivery time of a specific entry.
Alternatives
No response
Anything else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: