that the amount of I/O in the application (or, possibly, elsewhere in the system) must be re-
A second reason to monitor disk usage—even if the application is not expected to perform a
significant amount of I/O—is to help monitor if the system is swapping. Computers have a
fixed amount of physical memory, but they can run a set of applications that use a much lar-
ger amount of virtual memory. Applications tend to reserve more memory than they actually
need, and they usually operate on only a subset of their memory. In both cases, the operating
system can keep the unused parts of memory on disk, and page it into physical memory only
if it is needed.
For the most part, this kind of memory management works well, especially for interactive
and GUI programs (which is good, or your laptop would require much more memory than it
has). It works less well for server-based applications, since those applications tend to use
more of their memory. And it works particularly badly for any kind of Java application (in-
cluding a Swing-based GUI application running on your desktop) because of the Java heap.
More details about that appear in Chapter 5 .
A system that is swapping—moving pages of data from main memory to disk and vice
versa—will have generally bad performance. Other system tools can also report if the system
is swapping; for example, the vmstat output has two columns ( si , for swap in, and so , for
swap out) that alert us if the system is swapping. Disk activity is another indicator that swap-
ping might be occurring.
1. Monitoring disk usage is important for all applications. For applications that don't
directly write to disk, system swapping can still affect their performance.
2. Applications that write to disk can be bottlenecked both because they are writing
data inefficiently (too little throughput) or because they are writing too much data
(too much throughput).
If you are running an application that uses the network—for example, a Java EE application
server—then you must monitor the network traffic as well. Network usage is similar to disk
traffic: the application might be inefficiently using the network so that bandwidth is too low,