-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Consider avoiding Concurrent.processor_count when setting default background_worker_threads #2297
Comments
I do think 8 is too high, @st0012 opinions? |
I was thinking about this a bit more (apologies if this is more complicating than helping) but it seems to me that if we did 1 thread by default, the only real risk is that you might have more than 30 (the default) items in the queue at which point they'd start being dropped (at least that's my understanding according to the docs). My thinking is that we could try pushing down to 1 thread and sending an event (or logs or something) if we see items being dropped, so the customer would know they need to increase the thread count? |
I agree that we should probably lower the worker threads, thanks for raising this.
This potentially means that some customers would need to redeploy (potentially multiple times) to adjust the thread count after we push such changes, which would likely be a pretty negative experience. Considering that the current default has existed for more than 3 years and we only have received a report now, IMO the potential benefit doesn't justify the risk.
How about we start with I think the biggest problem is that It's also worth noting that while we could check the executor's current event size manually to collect the info ourselves, forcing it to synchronize repeatedly will likely hamper the performance of the executor. |
I would be fine with this.
We already collect |
Thanks for the consideration! FWIW I would say there's a definite improvement in terms of memory savings, so it's really worth considering doing something here, but I'm not sure what's best. I'm wondering if perhaps we could start even with just a generator and/or documentation change. I think I'm sensing a trend that I think the Also, let me know if me submitting an issue re: |
yea I'll do it as part of the 6.0 major |
@sl0thentr0py I think it should be fine to release such change in a minor or even patch release, so I opened #2305 against |
* Decrease the default number of background worker threads by half See #2297 for the discussion. * Update changelog
👋 look what I just came across! ruby-concurrency/concurrent-ruby#1038 (see linked commits showing this making its way into Rails as well...) |
oh nice should we just use |
Just wanted to bump this again in case it's potentially useful ^ |
@trevorturk sorry for the delay and thanks for raising this. I've opened #2339 to adopt the new API 😄 |
Issue Description
Since #1155 we have the ability to configure
background_worker_threads
which currently defaults to `Concurrent.processor_count. However, this config is likely to be too high in a shared hosting environment, leading to unnecessary memory usage. It may make sense to change the default to, say, a static 1 or 3 and add documentation about how best to configure?See also: https://github.com/rails/rails/pull/50669/files#diff-e25cab4832f078ca2f9dffa8918f895c8474f8086878e4ced9f5795131fc2de2R32
/cc @st0012
Feel free to disregard, since this is easy to correct, but in my case I was surprised at the impact lowering from 8 to 1 made on my memory use on Heroku.
Reproduction Steps
Expected Behavior
Consider defaulting to a static/lower number of background_worker_threads.
Actual Behavior
Defaults to
Concurrent.processor_count
.Ruby Version
3.3.3
SDK Version
5.17.3
Integration and Its Version
No response
Sentry Config
No response
The text was updated successfully, but these errors were encountered: