Skip to content
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

Queue enhancement: Costs per task #226

Closed
dereuromark opened this issue Apr 23, 2019 · 1 comment · Fixed by #231
Closed

Queue enhancement: Costs per task #226

dereuromark opened this issue Apr 23, 2019 · 1 comment · Fixed by #231

Comments

@dereuromark
Copy link
Owner

We currently have a prio system in place, across all tasks.
We also have a basic limitation of workers per server in place.

However, some tasks are more expensive (CPU, memory) than others and might either need to run completely on their own on a server, or other workers can only fetch very lightweight (cost) tasks to process in parallel to avoid server-overload.
How do we manage this?

One idea is to add a config to each task of a cost score (0-100), and if you fetched already a 60-cost task (high memory or CPU), any worker on the same server can only fetch tasks with < 40.
The cost per server can easily be summed up if stored in the processes table.

This way each server cant be overloaded that easily as it currently can, e.g. if 2x composer update is run using each 2GB of memory and each usually almost full CPU, competing against each other and often leading to unfinished job after timeout, forcing a re-schedule.

Other ideas? Or does this make sense?

@dereuromark
Copy link
Owner Author

dereuromark commented Apr 23, 2019

While checking the code I found a rather hidden and undocumented feature from 10 years ago, around "rate"
https://github.com/dereuromark/cakephp-queue/blob/master/src/Model/Table/QueuedJobsTable.php#L416

It basically looks for a "rate" config on the task class to determine how many of the same job can run simultaneously and with how much time in between.

if (property_exists($this->{$taskName}, 'rate')) {
	$this->_taskConf[$taskName]['rate'] = $this->{$taskName}->rate;
}

and

if (array_key_exists('rate', $task) && $tmp['job_type'] && array_key_exists($tmp['job_type'], $this->rateHistory)) {

But that is yet another topic of "what tasks can run in parallel, and which ones need to always run in sequence".

This rate history seems to be not only server but even worker specific though, and should probably be removed/refactored as well.

@dereuromark dereuromark added this to the 4.x milestone Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant