mirror of
https://github.com/friendica/friendica
synced 2025-04-28 17:04:23 +02:00
Makes the linear load calculation optional
This commit is contained in:
parent
533fedf9b8
commit
00124f9ac0
2 changed files with 28 additions and 9 deletions
|
@ -624,16 +624,34 @@ class Worker
|
|||
$load = current_load();
|
||||
if ($load) {
|
||||
$maxsysload = intval(Config::get("system", "maxloadavg", 50));
|
||||
$tinyload = 1;
|
||||
|
||||
if ($load > $maxsysload) {
|
||||
$queues = 0;
|
||||
} elseif ($load > $tinyload) {
|
||||
//Provide $queues number between 1 (below max load) and $maxqueues - 1 (above tiny load).
|
||||
$range = $maxsysload - $tinyload;
|
||||
$slope = 1.00 - (($load - $tinyload) / $range);
|
||||
$target = $slope * ($maxqueues - 1);
|
||||
$queues = intval(ceil($target));
|
||||
if (Config::get('system', 'worker_linear_load', false)) {
|
||||
/* The linear load calculation works fine if there is a low
|
||||
* number of maximum queues and a high load base level.
|
||||
* This can be present at shared hosters.
|
||||
*/
|
||||
$tinyload = 1;
|
||||
|
||||
if ($load > $maxsysload) {
|
||||
$queues = 0;
|
||||
} elseif ($load > $tinyload) {
|
||||
//Provide $queues number between 1 (below max load) and $maxqueues - 1 (above tiny load).
|
||||
$range = $maxsysload - $tinyload;
|
||||
$slope = 1.00 - (($load - $tinyload) / $range);
|
||||
$target = $slope * ($maxqueues - 1);
|
||||
$queues = intval(ceil($target));
|
||||
}
|
||||
} else {
|
||||
/* The exponentional load calculation respects the load behaviour
|
||||
* of Linux systems with regular hardware that normally idles
|
||||
* with load values near 0.
|
||||
*/
|
||||
$maxworkers = $queues;
|
||||
|
||||
// Some magical mathemathics to reduce the workers
|
||||
$exponent = 3;
|
||||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||
}
|
||||
|
||||
$processlist = '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue