UNIX Load Average Part 1: How It Works
teamquest.com
teamquest.com
It also has a bunch of other options.
On my own system, I also generally run "ps auwx" every 15 minutes, together with a scan of what queries Postgres servers are doing and dump of web request activity (read last 10k lines from access logs, find out how long ago the first request was to determine rough hits per second and ares of application they hit). That way when someone says "hey, the system was slow around this time" I can go back and find out that some cron job had a dozen processes taking up tons of memory or blocking on IO.
Some of those statistics also go into some RRD-based system which makes it easier to follow e.g. number of users logged in or number of Apache children based on weekday/time of day.
If you run "sar -q" you could get the load average information, but that's not particularly useful, as you can't see whether the 20 load avg an hour ago was caused by heavy disk IO or a dozen CPU bound processes.
# lsb_release -d
Description: Red Hat Enterprise Linux Server release 5.3 (Tikanga)
# rpm -qf $(which sar)
sysstat-7.0.2-3.el5
# strace /usr/lib64/sa/sa1 1 1 &> results
# grep open results
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libtermcap.so.2", O_RDONLY) = 3
open("/lib64/libdl.so.2", O_RDONLY) = 3
open("/lib64/libc.so.6", O_RDONLY) = 3
open("/dev/tty", O_RDWR|O_NONBLOCK) = 3
open("/proc/meminfo", O_RDONLY) = 3
open("/usr/lib64/sa/sa1", O_RDONLY) = 3
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libc.so.6", O_RDONLY) = 3
open("/etc/localtime", O_RDONLY) = 3
open("/sys/devices/system/cpu", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3
open("/proc/tty/driver/serial", O_RDONLY) = 3
open("/proc/interrupts", O_RDONLY) = 3
open("/proc/net/dev", O_RDONLY) = 3
open("/proc/diskstats", O_RDONLY) = 3
open("/var/log/sa/sa06", O_RDWR|O_APPEND) = 3
open("/proc/stat", O_RDONLY) = 4
open("/proc/meminfo", O_RDONLY) = 4
open("/proc/loadavg", O_RDONLY) = 4
open("/proc/vmstat", O_RDONLY) = 4
open("/proc/sys/fs/dentry-state", O_RDONLY) = 4
open("/proc/sys/fs/file-nr", O_RDONLY) = 4
open("/proc/sys/fs/inode-state", O_RDONLY) = 4
open("/proc/sys/fs/super-max", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/sys/fs/dquot-max", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/sys/kernel/rtsig-max", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/net/sockstat", O_RDONLY) = 4
open("/proc/net/rpc/nfs", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/net/rpc/nfsd", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/proc/diskstats", O_RDONLY) = 4
open("/proc/tty/driver/serial", O_RDONLY) = 4
open("/proc/interrupts", O_RDONLY) = 4
open("/proc/net/dev", O_RDONLY) = 4
# strace top -n -b 1 &> results
# grep open results
open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib64/libproc-3.2.7.so", O_RDONLY) = 3
open("/usr/lib64/libncurses.so.5", O_RDONLY) = 3
open("/lib64/libc.so.6", O_RDONLY) = 3
open("/lib64/libdl.so.2", O_RDONLY) = 3
open("/proc/stat", O_RDONLY) = 3
open("/proc/sys/kernel/pid_max", O_RDONLY) = 3
open("/etc/toprc", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/root/.toprc", O_RDONLY) = -1 ENOENT (No such file or directory)All I know is that when it's inexplicably over 3-4, you can't determine why as (no processes are using high CPU), and 1 in ten database queries are taking to 5 minutes, under normal load, that day will not be the best of your life. Well, what I've determined is that a full storage device, or overloaded i/o system for your disk, can produce very high load along with accompanying performance of doom.
The short answer is: it should be smaller than the number of cpu cores you have, if the sort of tasks you're running are actually using the cpu (vs just dispatching I/O, for example). A 24-core machine with load averages in their teens is still pretty responsive. Then again, considering that the right definition should specifically say that it's the number of processes in the 'Runnable' state.
It's a measurement of the CPU as a performance bottleneck. Other bottlenecks (e.g. your disk(s)) aren't covered.
I'm afraid that's incorrect. Any process blocked on disk i/o is considered as part of the load average.
Depends on the box. Say you:
a) have an app that spawns worker threads on demand and doesn't have a limit
b) Have a modern, cheap Nehalem X5600 CPU.
2 sockets * 6 cores * 2 threads per socket mean you're only fully realizing the investment when you have a load average of 24 (assuming that each of these cores is 0% idle, which you can tell with eg top).
High IO would show up as high %system time vs %user.
you can't determine why as (no processes are using high CPU)
Roughly, the load avg is the length of the run queue (how many processes are waiting to be run or are being run, vs. how many processor cores are available) with some IO activity thrown in for good measure. It could be a lot of IO wait or a lot of small processes that are driving up the load avg -- not necessarily just one process trying to hog CPU time.
There are a lot of good suggestions here -- many sysadms are too reliant on load avg (myself somewhat included).
As you've figured out this can happen because of a full storage device (causing writes to fragment as it squeezes data into small empty spaces, which causes what could have been one write to be many, which adds lots of seek time) or overloaded I/O causing the pre-fetch/caching tricks to stop working, causing everything to slow down.
The best solution is to never get into this situation in the first place. The second best solution is to find a way to halt I/O to the afflicted device until the system gets sorted out, figure out what was wrong, then add load and get back to a running state. The worst solution is to let things limp along until diminished load hopefully lets the disk get through its backlog and go back to normal.
1. Load averages are not directly comparable across different versions of Unix's such as FreeBSD, Linux, Solaris, etc.
2. Load average is a good way to quickly check if there is anything else to look at.
However, a far better series of tools is sar plus iostat , vmstat etc. which should help you more quickly determine whether your problem is CPU, disk, or network IO .
If you're not in thread mode in top, this is why you will sometimes see a process consuming > 100% CPU usage.
The average number of threads/processes in the run queue and/or blocked on disk i/o sampled at 1, 5, and 15 minutes.
From what I've read, measuring the actual total memory consumption of an individual process is nontrivial on both Mac OSX and Linux, because of the way the stats are generated for things like ps, top, etc. and the way both kernels share memory between processes whenever possible.
Load average can tell you if the system is under-used, but it can't tell you how the system is over-used.
I regularly have a few dual core systems spike to load averages of 50+ because of suboptimal NFS mounts. The NFS issue keeps processes waiting around with nothing to do for a while. Those processes are still counted towards the "load" even though they have no CPU activity (they are blocked on IO).
Shown in top as being in the 'D' state.
It is a useful metric to start digging deeper into the machine.
Maybe we should re-define load average, as the old definition divided by the number of cores.