Throttling on arbitrary resources.

Implements throttling for arbitrary resources.
https://github.com/seomoz/qless-core/issues/27

Currently running in our production system with 14k worker processes spread across 15 redis processes.

Created a throttle object model in qless-core which consists of a active job set, a pending job set, and a maximum value. The throttle controls how many jobs that can run simultaneously.

Modified the put command to attempt to throttle new jobs. This is to prevent wasting pops to move jobs into the throttled state.

Modified the pop command to check if all the throttles for the job are available and if not to add it to pending queue for one of the throttles.

Modified the complete, fail, retry commands to release all throttles associated with the job.

When a throttle is released the throttle checks its pending job set and inserts up to (maximum - active) jobs into the waiting queue to be popped.

Let me know of any questions, changes that need to be made etc.


This test doesn't really make sense to me...the name suggests that you are testing that dependencies can acquire a throttle lock after the job they depend on fails, but that doesn't sound like desirable behavior to me.  Dependencies shouldn't be able to tun until the jobs they depend on have completed.

Also, I don't actually see how the assertions in this test demonstrate anything...`pop` is only called once and it gets `jid1`.  After it fails, no further pops are attempted.

What is this trying to test?