Improve /metrics endpoint performance - #14453
Conversation
|
Tests to be completed |
|
Cancel write metrics data to file, cache buf only. |
…prometheus_performance
… usage increasing.
… usage increasing.
eolivelli
left a comment
There was a problem hiding this comment.
Nice work.
We should make this configurable. In case we have a bug and we want to disable this feature
Jason918
left a comment
There was a problem hiding this comment.
Persist metrics data into temp file, send it to client by send_file.
Do you actual use file IOs? If so, please help point it out.
Generally, it seems this is a nice optimization, but do we have any downside of this feature?
Canceled persist data to temp files, maybe broker has a poor performance disk, so use
When pulsar has to export more than 50MB metrics data, there will be cause high heap memory usage, high GC pressure and high CPU usage. The pr is for the purpose of fix it. |
Actually, I am just curious if there is some situation that it's better not use this feature, maybe like metric data is under 50MB? |
|
Thanks.
This feature is a precursor. What I want is in the future we can clean all the metrics objects after metrics data generated, it could release a lot of objects and reduce heap memory usage if there are over 1 million topics in a broker. |
…prometheus_performance
…prometheus_performance
|
Make cache-metrics-data configurable |
eolivelli
left a comment
There was a problem hiding this comment.
Overall LGTM
Can you also add the configuration entry to broker.conf and proxy.conf ?
# Conflicts: # site2/docs/reference-configuration.md
|
@eolivelli @Jason918 hi,this PR has blocked for a long time, if there are no more change requests, could you please help approve? |
# Conflicts: # pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGenerator.java
…prometheus_performance � Conflicts: � conf/proxy.conf


Motivation
PrometheusMetricsGenerator#generateinvoke in a period(1 minute), for the purpose of saving memory and reducing CPU usage.send_file. Avoid huge heap memory allocations, too muchmem_copyoperations, too much memory resizes, high GC pressure and high CPU usage.Modifications
PrometheusMetricsGenerator#generate, invokePrometheusMetricsGenerator#generateonce in a period, cache the result and return to client directly.send_file.Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation
Check the box below or label this PR directly (if you have committer privilege).
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)