-
Notifications
You must be signed in to change notification settings - Fork 149
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 DirectFileStore memory overhead, particularly while aggregating data when getting scraped #185
Comments
Hello, thank you for this report! I may be misunderstanding the problem, but it seems like you are running out of memory? Are you reporting this as a bug in the Prometheus Client? The more details you can add, the better. |
Yes, we've encountered this after installing the library 🥺
I'm not quite sure if this is a bug or we need to configure extra options for the Prometheus Client. Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFileStore.new(dir: '/tmp/prometheus_direct_file_store')
Sorry, I meant to release the file store or memory properly https://github.com/prometheus/client_ruby#directfilestore-caveats-and-things-to-keep-in-mind
I wonder while aggregating the files, when do they release the memory or the file store that was configured. I suppose this is the issue here?
I currently don't have simple code the replicate the issue, but I'll try. Thanks a lot! |
In my opinion, this isn't a bug in the library. And I don't think there are configuration options that will help with this. We have looked into memory usage in our production environment specifically looking for a memory leak, and we don't think there is one. I don't think this is an issue with releasing memory properly.
From your stack trace, i'm under the impression the error happened when observing a histogram, not when aggregating the files, although of course some other request could have been aggregating results at the same time and using more RAM. As for your specific question, we read all files by opening them and closing them after we've read each of them, details here but we do keep all the data that we read from all of them in memory until the request is finished, as we need it to aggregate all the values and generate the response. There have been some efforts to limit this memory usage, like this one. If it's ok with you, i'm going to change this issue's title and description to reflect the fact that we want to reduce memory usage, rather than it looking like an exception, which will make it more approachable for anyone that would like to help improve this. |
Thanks a lot! |
As we mention in our README, using DirectFileStore has a measurable impact on the production app's memory usage.
This doesn't seem to be a memory leak, it doesn't grow unbounded over time, but it is a problem for some of our users.
We think this memory usage is particularly high when getting scraped, at which point the library has to read all the files from all the processes, and load all the data in RAM to aggregate it. There may be more efficient ways to do this. As an example, we've found this improvement in the past.
We'd like to reduce the memory overhead of using DirectFileStore as much as possible, so this is a sort of call for PRs.
Original issue text below, for the conversation thread below to make sense:
Hi Prometheus team,
We've bumped into issues like this
Is there any possibility to dump the file store properly?
The text was updated successfully, but these errors were encountered: