What exactly is a load average?
Linux July 27th, 2007 - 32,185 views
If you’ve spent some time on a Unix or Unix-like machine (e.g., Linux, OS X, Solaris, etc.) then you’re probably at least vaguely familiar with the concept of a load average. A system’s load average can be easily determined from the Unix shell by running the uptime command:
mmalone@www:~$ uptime
15:37:38 up 133 days, 3:37, 3 users,
load average: 0.37, 0.37, 0.41
The load average is also displayed by the w and top commands, and by pretty much every system monitoring package on the planet. But what the heck is a load average, exactly?
To most people, a load average is some mysterious number that is somehow related to the amount of work that their computer is currently handling. But what is a good load average, and how high is too high? The answer is actually quite simple. But first you have to understand what the load average is actually measuring.
Without getting into the vagaries of every Unix-like operating system in existence, the load average more or less represents the average number of processes that are in the running (using the CPU) or runnable (waiting for the CPU) states. One notable exception exists: Linux includes processes in uninterruptible sleep states, typically waiting for some I/O activity to complete. This can markedly increase the load average on Linux systems.
The load average is calculated as an exponential moving average of the load number (the number of processes that are running or runnable). The three numbers returned as the system’s load average represent the one, five, and fifteen minute moving load average of the system.
So, for a single processor machine a load average of 1 means that, on average, there is always a process in the running or runnable state. Thus, the CPU is being utilized 100% of the time and is at capacity. If you tried to run another process, it would have to wait in the run queue before being executed. For multiprocessor systems, however, the system isn’t CPU bound until the load average equals the number of processors (or cores, for multi-core processors) in the machine. My database server, for example, has two dual core processors. Thus, the system isn’t fully utilized until the load average reaches 4.
In summary, the load average is a moving average of the number of processes in the running or runnable states. You shouldn’t be worried about your system’s load unless it is consistently higher than the number of processors (or cores) in your machine. In general, you can calculate a system’s CPU utilization by dividing the load average by the number of processors/cores in the system.
July 27th, 2007 at 4:54 pm
Great post. I’ve been running/managing Linux on and off for over 5 years and I still only had a vague idea of what load was and that the lower the better, I just didn’t know how Linux calculated all of the decimals.
July 30th, 2007 at 1:34 pm
Nice Info. I now know why I’m getting high load average, Usually my Eclipse-forked Java runs many threads (processes in linux) in background. So It seems to me that these threads are also included in calculating the moving average.
July 30th, 2007 at 1:49 pm
Threads and processes are technically different things, but you’re right: Eclipse probably puts a significant load on your system. In fact, any GUI will probably put a fairly large load on a system simply due to the real-time nature of a graphical interface. Threads are somtimes handled differently than processes, but I believe Linux treats them the same when calculating the load average (someone please correct me if I’m wrong).
July 30th, 2007 at 1:54 pm
AFAIK, In Linux there’s single flag in process control block to differenciate a thread from block.
July 30th, 2007 at 1:56 pm
Opps I meant,
AFAIK, In Linux there’s single flag in process control block to differenciate a thread from a process.
:)
July 31st, 2007 at 3:31 am
If I understand this correctly the relation between load average and CPU usage is as you say: “you can calculate a system’s CPU utilization by dividing the load average by the number of processors/cores in the system.”
So does 1 mean roughly 100% CPU usage?
According to rate-monotonic-scheduling (http://en.wikipedia.org/wiki/Rate-monotonic_scheduling) if your system exceeds 70% CPU usage it’s even under trivial conditions (excluding harmonic tasks) not schedulable anymore, which means processes/threads are guaranteed to miss their deadlines, which leads at least to a degradation in system behavior.
Am I missing something?
Can you please tell me how you see the relation between load average, CPU usage and rate-monotonic scheduling?
July 31st, 2007 at 11:34 am
The difference is that, as you inferred, harmonic tasks and other randomness throws things off. With CPU usage you can’t exceed 100% (for a single processor). Load, on the other hand, has no upper bound (theoretically).
If you’re at a steady state with CPU usage over 70% or so, the system can’t be scheduled in such a way that all tasks will complete. Likewise, if you’re in a perfectly steady state with a load above 0.7, I’d say you’re probably in trouble (depends on OS, and many other factors). But the fact is, particularly for a server, usage varies. Since the run queue can exceed 1, and it’s generally calculated via sampling, you might have two samples that return 10 and 0 processes in the run queue, respectively. That gives you a load average of 5, but your system is still usable/schedulable.
As far as I know there is no theoretical model that uses the load average to determine whether a system is schedulable. This would be particularly difficult to do in general because load is so loosely defined, and the algorithm varies slightly between operating systems.
August 2nd, 2007 at 9:13 am
A few weeks ago I was wondering about this same question,
and found the wikipedia page on the subject quite helpful:
http://en.wikipedia.org/wiki/Load_(computing)
cheers,
– daniel
August 3rd, 2007 at 6:01 am
[...] habe bei I’m Mike gerade eine sehr gute Erklärung gefunden, was eigentlich die Load Average [...]
August 7th, 2007 at 7:58 am
Great post. thank you.
i will buy u a beer some time..
August 13th, 2007 at 9:48 pm
[...] then selectively adding dynamic functionality where it’s necessary will drastically reduce the load on your [...]
October 24th, 2007 at 10:42 am
Well Mike, thank you again. My random google searching has again led me unknowingly to your website for some helpful tips. Now will you sign up for linkspaid.com and make some money off this gold mine of yours already????