resque / resque-scheduler

A light-weight job scheduling system built on top of Resque
MIT License
1.74k stars 481 forks source link

scalability: delaying large number of tasks #190

Open assembler opened 11 years ago

assembler commented 11 years ago

From reading the source, scheduler is going to handle_delayed_items each 5 seconds (sleep interval).

This method is going to take the next timestamp from the queue and process all tasks associated with that timestamp.

If i have huge amount of tasks which are scheduled (delayed) to be run like this:

Scheduler is going to run like this:

If these repeated tasks are infinite, scheduler will keep lagging more and more as the time passes.

I see two solutions to this:

  1. set sleep interval to 1s
  2. refactor handle_delayed_items to keep looping until next_delayed_timestamp reaches the current timestamp
assembler commented 11 years ago

or third option: refactor my app no to schedule tasks in intervals smaller than poll_sleep_amount (5 seconds)

ksinkar commented 10 years ago

@assembler, Can you give a unit test in a PR against which we can program and implement this feature. Maybe we can give a an external configuration setting for the sleep interval.

rohitpaulk commented 3 months ago

This seems to be handled now, tasks are enqueued in a loop until no more timestamps currently have tasks: https://github.com/resque/resque-scheduler/blob/5d7a4e1d4ef33c37e9c05c9a91236e7ef12e1529/lib/resque/scheduler.rb#L189-L192