-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Uneven job scheduling in rate-limited grouped queues #32
Comments
Interesting. One thing to try might be to randomize each timer interval. Jobs doesn't depend on the timers firing exactly, but will calculate for each actual interval how many jobs to allow. I don't have time to try this right now, but if you feel up to it, please feel free. |
Any idea were to start? |
Well, perhaps the simplest way to start would be to write a callback for https://github.com/uwiger/jobs/blob/master/src/jobs_server.erl#L1745 This would also give an indication of where to try to fix the But if you create your queues with Things to consider: If the interval is too short, compared to the expected rate, precision may suffer. If the interval is too long, jobs may end up waiting unnecessarily before being dispatched. But basically, if you introduce sufficient jitter in the intervals, it might be possible to avoid systematic starving of a certain queue (assuming this is caused by too much determinism in the dispatch.) |
Rate-limited queue group with rate-limited queues are not scheduled evenly. First queue is always suffering.
Expected behaviour is for the queues to be fairly scheduled in a group rate limit scenario.
Details
I've created a demo project showing this behaviour: x4lldux/jobs_group_queues repo (Elixir project, sorry).
Running
Aggregator.test(n_queues, n_procs)
creates a group rate limit (hardcoded 5 req/s in this demo), nqueues rate limited queues (hardcoded to 3 req/s) and nprocs processes per queue. Queues are numbered from 0..nqueues-1. Each process will ask it's respective queue for a permission, and when granted, send a message toAggregator
gen_server.After all process send their messages (it takes approximately nprocs seconds), a "sum up" list is returned, where each element is a tuple containing time, a tuple with numbers of grants/messages sent for each queue (up to that point in time) and a list of queues activated in that time frame (per second).
This creates 5 queues and 30 process per queue:
In this example first queue is rarely scheduled until most of the other queues are done. The last 10 seconds is spent solely scheduling the first queue because all others have already finished.
The text was updated successfully, but these errors were encountered: