-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Reduce memory usage of elasticsearch.index
metricset
#16538
Conversation
f188eef
to
98a6d28
Compare
Pinging @elastic/integrations-services (Team:Services) |
How big of a problem is it that we have to use a manual parsing approach? We still produce some structured contents. Plus Metricbeat does not acquire these metrics like every 1s. Do we have numbers like before/after? |
Chatted with @urso about this off-PR. We already know that the high memory consumption is coming from parsing the JSON from the Stats API response. He noticed that we were parsing into a
He suggested parsing into I did that and here are the results:
Parsing a 4.8MB JSON API response into So I'm going to amend this PR accordingly — we will not switch to a streaming JSON parser, instead we will simply parse into |
98a6d28
to
0bf1bcf
Compare
jenkins, test this |
56f44de
to
219d58c
Compare
219d58c
to
79878a2
Compare
THIS COMMIT MUST BE REMOVED AT THE END!!!
79878a2
to
7bdccfd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Travis CI is green and Jenkins CI failures are unrelated. Merging. |
…#17069) * Reduce memory usage of `elasticsearch.index` metricset (#16538) * [Debugging only!] Add charts to see memory usage over time. THIS COMMIT MUST BE REMOVED AT THE END!!! * [Debugging only] Disable validation so we can test only index metricset * Streaming parser * Removing debugcharts * Replace maps with structs * Running go mod tidy * Pass pointer * Uncomment code * Reverting unnecessary changes * Adding CHANGELOG entry * Incorporating benchmark test * Removing unnecessary nil check * Fixing up bad rebase
…#17070) * Reduce memory usage of `elasticsearch.index` metricset (#16538) * [Debugging only!] Add charts to see memory usage over time. THIS COMMIT MUST BE REMOVED AT THE END!!! * [Debugging only] Disable validation so we can test only index metricset * Streaming parser * Removing debugcharts * Replace maps with structs * Running go mod tidy * Pass pointer * Uncomment code * Reverting unnecessary changes * Adding CHANGELOG entry * Incorporating benchmark test * Removing unnecessary nil check * Fixing up CHANGELOG * Fixing up bad rebase
What does this PR do?
This PR reduces the memory usage of the
elasticsearch.index
metricset by parsing the JSON API response from Elasticsearch intostruct
s instead ofmap[string]interface{}
.Why is it important?
To reduce the overall memory footprint of Metricbeat which makes it less susceptible to the OOM Killer and such.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature worksBenchmarking test added in Benchmark API response parsing code #17046 is used to prove the improvement in memory usage after this PR.How to test this PR locally
Sample benchmark results
Before this PR
In terms of memory, the API response parsing implementation before this PR consumed 13.46 MB.
After this PR
In terms of memory, the API response parsing implementation after this PR consumed 0.59 MB.
That's an improvement of approximately 1:22!
Related issues