Reduce memory usage of elasticsearch.index metricset#16538
Reduce memory usage of elasticsearch.index metricset#16538ycombinator merged 12 commits intoelastic:masterfrom ycombinator:mb-es-xp-mem-usage
elasticsearch.index metricset#16538Conversation
|
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 |
|
jenkins, test this |
THIS COMMIT MUST BE REMOVED AT THE END!!!
|
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.indexmetricset by parsing the JSON API response from Elasticsearch intostructs 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