-
Notifications
You must be signed in to change notification settings - Fork 956
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
delayed_job process on OSX consistently consuming massive amounts of system resources #821
Comments
Start with updating DJ. Then look for anything you have that might be triggering a background thread. Also look for anything that you have running in the worker loop hook. |
When I posted the issue four months ago I had updated everything from DJ to Ruby. I was using DJ purely for sending mails and analytics tracking - no heavy lifting. |
Might be due to delayed_job reloading the app too often.
@albus522 do you think we could be more clever on when to reload the app ? |
We're also seeing Delayed Job consume a lot of CPU when the job queue is empty. Setting @albus522 - Could we instead trigger code reloading before running each job which is the moral equivalent of what Rails is doing with web requests? I'm happy to put together a PR if you'd be open to folding in the change. |
For anyone interested here's a monkey patch that causes workers to only reload code before running a job rather than during each iteration of the job polling loop. On my machine it cuts CPU usage of an idle worker from 30% to 0.2%. module Delayed::WorkerClassReloadingPatch
# Override Delayed::Worker#reserve_job to optionally reload classes before running a job
def reserve_job(*)
job = super
if job && self.class.reload_app?
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
end
job
end
# Override Delayed::Worker#reload! which is called from the job polling loop to not reload classes
def reload!
# no-op
end
end
Delayed::Worker.send(:prepend, Delayed::WorkerClassReloadingPatch) EDIT: Updated this to override |
If you are using ActiveJob, you can simply disable delayed_job's reload feature. |
+1. We started seeing this problem in Sierra dev environment when we upgraded to Rails 5. We've tried @jturkel's solution and others, nothing has worked so far. |
Closing stale |
I've had this issue for a while on Yosemite, and it still persists after a reinstall. When starting delayed_job, it runs fine for a few minutes, after which the ruby process starts eating more and more CPU resources until it caps out at 100% and brings the Mac to a halt. The job queue is empty while this happens. Looking at CPU usage, it seems to start with the usage of the Ruby process shooting up every few seconds, and then gets worse and worse. Not sure where to even start looking for the issue?
I'm on OSX 10.10.3 (although it happened on earlier versions as well), Ruby 2.2.2 (it also happened on previous versions) and delayed_job 4.0.6.
The text was updated successfully, but these errors were encountered: