This module can be used to protect your server in case system load or memory use goes too high.
To use this module, you should enable it first:
server {
sysguard on;
sysguard_load load=10.5 action=/loadlimit;
sysguard_mem swapratio=20% action=/swaplimit;
sysguard_mem free=100M action=/memlimit;
location /loadlimit {
return 503;
}
location /swaplimit {
return 503;
}
location /memlimit {
return 503;
}
}
Note this module requires the sysinfo(2) system call, or getloadavg(3) function in glibc. It also requires the /proc file system to get memory information.
Turn on or off this module.
Specify the load threshold.
When the system load exceeds this threshold, all subsequent requests will be redirected to the URL specified by the 'action' parameter. Tengine will return 503 if there's no 'action' URL defined.Specify the used swap memory or free memory threshold.
When the swap memory use ratio exceeds this threshold or memory free less than the size, all subsequent requests will be redirected to the URL specified by the 'action' parameter. Tengine will return 503 if there's no 'action' URL. Sysguard uses this strategy to calculate memory free: "memfree = free + buffered + cached"Specify the time interval to update your system information.
The default value is one second, which means tengine updates the server status once a second.Specify the log level of sysguard.