Skip to content

Comments

Robust and more Strict job throttling#20

Open
parikshit223933 wants to merge 10 commits intomalomalo:masterfrom
CodingNinjasHQ:master
Open

Robust and more Strict job throttling#20
parikshit223933 wants to merge 10 commits intomalomalo:masterfrom
CodingNinjasHQ:master

Conversation

@parikshit223933
Copy link

We have two machines running on production all the time and 10 workers are running on each machine. We were having trouble with resque throttler because throttling was not precise. sometimes it would dequeue jobs mentioned in the throttling config and sometimes more than that. We needed strict throttline as per the given config. This PR ensures that.

Let me know your opinion on the same.

@parikshit223933 parikshit223933 changed the title Rebost and more Strict job throttling Robust and more Strict job throttling Dec 2, 2024
parikshit223933 and others added 5 commits July 25, 2025 13:44
This commit adds the ability to limit the number of jobs that can run concurrently for a queue, in addition to the existing rate limiting functionality.

Key changes:
- Add :concurrent option to rate_limit configuration
- Track active jobs using Redis counters
- Override Worker#perform to increment/decrement active job counts
- Check concurrent limits in Worker#reserve before starting new jobs
- Add methods: active_job_count, queue_at_or_over_concurrent_limit?, etc.
- Update README with examples and documentation

This feature helps prevent resource exhaustion and database lock accumulation when jobs take longer than the rate limit window.

Example usage:
Resque.rate_limit(:my_queue, at: 5, per: 5, concurrent: 3)

This ensures max 5 jobs start per 5 seconds AND max 3 jobs run concurrently.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ting

Add concurrent job limiting feature
- Major version bump for new concurrent limiting feature
- Updated gem description to reflect new functionality
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.

1 participant