-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Improve Pulsar Broker cache defaults to get better out-of-the-box performance #23466
Comments
the changes to the cache eviction config changes look good. |
@grssam I agree. It's just that the current defaults are not optimal at all for most users. Users that fine tune configurations, should set the values explicitly. It could be helpful to add a way to have dynamic setting with lower and upper bounds. Perhaps supporting an expression language like SpEL or MVEL for evaluating the dynamic expression could be useful.
I also added more context for |
@dao-jun is planning to contribute the offloading dashboard to Apache Pulsar project so that it could be included in https://github.com/apache/pulsar/tree/master/grafana/dashboards. |
This is completed by #23479 , thank you @dao-jun. dashboard is now available at https://github.com/apache/pulsar/blob/master/grafana/dashboards/offloader.json . |
An additional consideration is to set cacheEvictionByMarkDeletedPosition=true to prevent issue described in #16421 |
Most recent status update which touches upon |
There's currently an open issue #23900 where the broker cache is always by-passed for replay queue reads, also when |
Search before asking
Mailing list discussion thread: https://lists.apache.org/thread/5od69114jfrzo9dkbllxycq8o7ns341y
Motivation
It's crucial to tune the Pulsar broker cache since the defaults in Pulsar are not optimal. Besides poor performance for Pulsar use cases, this leads to wasted CPU and unnecessary network transfer costs in cloud environments.
Tuning the Pulsar broker cache improves performance and reduces costs, especially with high fan-out use cases, Key_Shared subscriptions, and tiered storage.
Solution
Here are some settings which would be better defaults.
maxMessagePublishBufferSizeInMB
- not broker cache related, but it's necessary to set it to an explicit value when fine-tuning broker cache settings so that direct memory OOM can be avoided. Default is 50% of direct memory. Set to500
managedLedgerCacheSizeMB
- the default is 20% of direct memory. It's better to set it to an explicit value to avoid direct memory OOM. Set to512
managedLedgerMaxReadsInFlightSizeInMB
- this feature is disabled by default. It's useful for avoiding direct memory OOM, which is a known issue with the defaultdispatcherDispatchMessagesInSubscriptionThread=true
setting unlessmanagedLedgerMaxReadsInFlightSizeInMB
is set. Set to500
. The value should be higher thandispatcherMaxReadBatchSize
*maxMessageSize
.managedLedgerCacheEvictionTimeThresholdMillis
- the default1000
is too low. Set to10000
managedLedgerCacheEvictionIntervalMs
- the default10
is too low. Set to5000
to avoid spending a lot of CPU with cache eviction.managedLedgerMinimumBacklogCursorsForCaching
- the default0
disables backlog cursors (catch-up read) caching. Set to3
managedLedgerMinimumBacklogEntriesForCaching
- the default1000
is way too high. Set to1
managedLedgerMaxBacklogBetweenCursorsForCaching
- the default10000
is way too low. Set to2147483647
to disable the limit completely.Sample settings for broker cache tuning:
yaml format:
broker.conf
format:managedLedgerMaxReadsInFlightSizeInMB
will have to be set to value that is higher thandispatcherMaxReadBatchSize
*maxMessageSize
. Otherwise it could result in errorTime-out elapsed while acquiring enough permits on the memory limiter to read from ledger [ledgerid], [topic], estimated read size [read size] bytes for [dispatcherMaxReadBatchSize] entries (check managedLedgerMaxReadsInFlightSizeInMB)
.dispatcherMaxReadBatchSize defaults to 100 and maxMessageSize defaults to 5MB in bytes.
There's a separate issue to address the problem when
managedLedgerMaxReadsInFlightSizeInMB
< ``dispatcherMaxReadBatchSize*
maxMessageSize`, #23482.Alternatives
No response
Anything else?
The broker cache hit rate can be monitored with the Grafana dashboard found at https://github.com/datastax/pulsar-helm-chart/blob/master/helm-chart-sources/pulsar/grafana-dashboards/broker-cache-by-broker.json (Apache 2.0 license). The broker cache also impacts offloading. Offloading can be monitored with the dashboard available at https://github.com/apache/pulsar/blob/master/grafana/dashboards/offloader.json .
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: