简体   繁体   中英

Rails dev server takes a long time to reload after codes changes

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 andhttps://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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM