I swear that this was not an issue in the past and I can't pinpoint when I think this changed. In my local development environment if I make ANY changes to my models / controllers my server takes at least 20-30 seconds to reload and respond to requests. This is Rails 5.2.3 and Thin 1.7.2. I don't recall it ever being this slow before. FYI I have config.cache_classes = false already which is the obvious culprit.
Any ideas here?
I've been fighting with this issue for some time and I seem to have found two solutions worth trying. I run Rails 7.0.4 and Puma 6.0.
After debugging with rack-mini-profiler, I noticed that Thread::Mutex#synchronize was very slow. ~30 seconds. So I figured lowering the number of Puma threads might help. It improved but didn't completely solve the problem for me.
To run Puma single-threaded, I put the following in my Procfile:
RAILS_MIN_THREADS=0 RAILS_MAX_THREADS=1 bin/rails s -p 3000
The problem I was experiencing seems to be more directly related to this bug in Puma 6.0.0, as discussed here: https://github.com/ElMassimo/vite_ruby/issues/299 and https://github.com/jumpstart-pro/jumpstart-pro-rails/issues/475
Downgrading to 5.6.5 completely eliminated the issue, and I was able to return to multi-threaded Puma.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With