return;
// Checking the number of workers
- if (poller_too_much_workers($entries, $queues, $maxqueues)) {
+ if (poller_too_much_workers($entries, $queues, $maxqueues, $active)) {
poller_kill_stale_workers();
return;
}
sleep(4);
// Checking number of workers
- if (poller_too_much_workers($entries, $queues, $maxqueues))
+ if (poller_too_much_workers($entries, $queues, $maxqueues, $active))
return;
$cooldown = Config::get("system", "worker_cooldown", 0);
return;
// Count active workers and compare them with a maximum value that depends on the load
- if (poller_too_much_workers($entries, $queues, $maxqueues))
+ if (poller_too_much_workers($entries, $queues, $maxqueues, $active))
return;
$argv = json_decode($r[0]["parameter"]);
/// @todo Better check for priority processes
$priority = array("delivery_run", "notifier_run", "pubsubpublish_run");
+ // Reserve a speed lane
+ if (($active == ($queues - 1)) AND ($maxqueues >= 2) AND !in_array($funcname, $priority)) {
+ logger("Delay call to '".$funcname."' to reserve a speed lane for high priority processes", LOGGER_DEBUG);
+ $delay = true;
+ }
+
// Delay other processes if the system has a high load and there are many pending processes.
// The "delayed" value is a safety mechanism for the case when there are no high priority processes in the queue.
- if ((($queues / $maxqueues) <= 0.5) AND (($entries > 100) AND ($delayed < 100)) AND !in_array($funcname, $priority)) {
- q("UPDATE `workerqueue` SET `created` = '%s' WHERE `id` = %d",
- dbesc(datetime_convert()),
- intval($r[0]["id"]));
-
+ if (!$delay AND (($queues / $maxqueues) <= 0.5) AND (($entries > 100) AND ($delayed < 100)) AND !in_array($funcname, $priority)) {
// Count the number of delayed processes
++$delayed;
logger("Delay call to '".$funcname."' for performance reasons (Delay ".$delayed.")", LOGGER_DEBUG);
+ $delay = true;
+ }
+
+ if ($delay) {
+ q("UPDATE `workerqueue` SET `created` = '%s' WHERE `id` = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]["id"]));
continue;
}
}
}
-function poller_too_much_workers(&$entries, &$queues, &$maxqueues) {
+function poller_too_much_workers(&$entries, &$queues, &$maxqueues, &$active) {
$entries = 0;