-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support throttling on arbitrary resource names #27
Comments
This just made my day. I like the idea a lot.I think it generalizes the throttling in a very useful way allowing much finer grained control over concurrency when jobs are using external resources. |
I like it as well. |
Yeah, the more I think about it, the more I like it being a set (not a list) of jids. If we used the counter and had a "counter leak", it doesn't provide the data to be able to troubleshoot what jobs are holding the resource. A jid set gives the you the details to be able to inspect all the jobs holding that resource.
I think the job's jid should be in the resource set only while it is in the |
On Aug 14, 2013, at 11:14 AM, Myron Marston wrote:
|
I'm going to create a fork of qless-core and implement this feature. Any feedback on the proposed implementation welcomed. Introduce a new class called QlessResource using the following keys
Extend the Extend the Extend the complete command, so that if the completing job has active resource locks, releases them, assigning them to the next pending job and moving it to the Extend the The patch will be documentation of the implementation details, but I'll be conscious of keeping things as efficient as possible. |
Was there ever a PR for this? I would love to see it added to master, so let me know if there is something I can do to help. |
Currently Qless supports throttling at a per-queue level. We have a need to due throttling on an arbitrary named resource (in our case a MySQL host in our shard ring). To prevent our MySQL hosts from getting overloaded, we've set a hard connection limit of 30 connections for our shard building jobs. We rescue and retry "too many connections" errors, but it would be more efficient if we could set a max concurrency per host, w/o having to put jobs in a per-host queue.
So...here's an idea for how we could refactor the current concurrency throttling to be more general:
queue.put(MyJobClass, { data: 15 }, throttlable_resources: ['foo', 'bar'])
.QlessJob#throttlable_resources
qless-core API will take care of adding the queue and klass names to this list when things request the throttlable resources).Pop()
it will increment the counter for each throttlable resource of the popped job.Pop()
it will also check that a potentially popped job's throttlabe resources all have available capacity by looking at the counters. If any of the counters are full, it won't pop that job, moving on in the queue to the next job.scard
can be used to get the count in O(1) time.In our use case, we would use MySQL host names as our throttable resources. This could supercede the existing per-queue throttling (as a queue name would be an implicit throttled resource and this could easily support that use case). It would also nicely support per-job-class throttling.
Thoughts, @dlecocq?
/cc @proby
The text was updated successfully, but these errors were encountered: