I'm trying delayed_job
now, and have some questions.
From the http://github.com/collectiveidea/delayed_job page, I can see some information:
Workers can be running on any computer, as long as they have access to the database and their clock is in sync. Keep in mind that each worker will check the database at least every 5 seconds.
When I invoke rake jobs:work
once, it will create ONE worker, right?
When a worker checks the database, it will read ALL new and failed tasks EACH TIME, and run them?
it says a worker will check the database every 5 seconds, can I make it 2 seconds?
When I create a worker(rake jobs:work
), there are already 10 tasks in the database, and each will take 3s. How many processes will DelayedJob create? And how many seconds need in total?
Delayed::Job works by serializing a Ruby object as YAML and storing it in a database table so that a worker in a different process can retrieve, deserialize, and perform the requested work. Some operations that we use Delayed::Job for are longer-running data processing, sending emails, and updating search indicies.
Delayed Job, also known as DJ, makes it easy to add background tasks to your Rails applications on Heroku. You can also use Resque and many other popular background queueing libraries. Delayed Job uses your database as a queue to process background jobs.
The most simple way to check whether delayed_job is running or not, is to check at locked_by field. This field will contain the worker or process locking/processing the job. Running Delayed::Job. where('locked_by is not null') will give you some results, if there are jobs running.
Delayed::Worker.sleep_delay = 2
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