Skip to content

Pipeline delayed job counting - #1

Merged
jbockler merged 2 commits into
jbockler:mainfrom
top-sigrid:pipeline-count-all-scheduled-jobs
May 11, 2026
Merged

jbockler merged 2 commits into
jbockler:mainfrom
top-sigrid:pipeline-count-all-scheduled-jobs

Conversation

@top-sigrid

@top-sigrid top-sigrid commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Resque.count_all_scheduled_jobs from resque-scheduler is very inefficient - issueing one sequential LLEN Redis call per delayed timestamp. With many delayed jobs this becomes the bottleneck during Prometheus metric collection, causing scrape timeouts.

This PR provides a pipelined version of count_all_scheduled_jobs. I intend to also contribute this to resque-scheduler itself, but for now I think this is also a good place here.

On our production system I measured this 18,6x faster counting all delayed jobs:

Jobs Timestamps Duration
Original (sequential) ~35,950 ~20,300 5,641ms
Pipelined ~35,950 ~20,300 304ms

@jbockler jbockler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 🙏
Even though i would rather see this in the resque-scheduler itself, adding this temporarily should be fine.

Comment thread lib/yabeda/resque.rb Outdated
@top-sigrid

Copy link
Copy Markdown
Contributor Author

Thanks for the PR 🙏 Even though i would rather see this in the resque-scheduler itself, adding this temporarily should be fine.

Thanks for being open to this! I agree and will definitely also contribute this to resque-scheduler itself as indicated in the PR description. I have some PRs waiting there for many months, so I hope it won't take forever. Up until then, we can battle test this version in production :p

@top-sigrid
top-sigrid requested a review from jbockler May 7, 2026 09:47
@jbockler
jbockler merged commit 4130fdc into jbockler:main May 11, 2026
@jbockler

Copy link
Copy Markdown
Owner

Released as 1.3.0 :)

@top-sigrid

Copy link
Copy Markdown
Contributor Author

I also opened a PR for resque-scheduler directly as discussed :) resque/resque-scheduler#822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants