sys_getloadavg()

sys_getloadavg() — Gets system load average.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.3, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns three samples representing the average system load (the number of processes in the system run queue) over the last 1, 5 and 15 minutes, respectively. Returns false on failure.

Signature

sys_getloadavg(): array|false

Parameters

This function takes no parameters.

Return value

Returns an array with three samples (last 1, 5 and 15 minutes).

Example

A runnable snippet:

$load = sys_getloadavg(); if ($load[0] > 0.80) { header('HTTP/1.1 503 Too busy, try again later'); die('Server too busy. Please try again later.'); }

All PHP 8.5 built-in functions

Reference card built from the PHP manual page sys_getloadavg() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.