No system runs as fast as we need it to run, and any computer's performance can be improved.
We can improve the performance of a system by turning off unused services, by tuning the kernel parameters, or by adding new hardware.
The first step in tuning a system is understanding what the demands are and whether they are being met. Different types of applications have different critical needs. The questions to ask yourself include the following:
- Is the CPU the critical resource for this system? A system doing engineering simulations requires CPU cycles more than other resources.
- Is network bandwidth critical for this system? A file server does little computation, but can saturate its network capacity.
- Is disk access speed critical for this system? A file server or database server will put more demand on the disks than a calculation engine does.
- Is RAM the critical resource for this system? All systems need RAM, but a database server commonly builds large in-memory tables to perform queries, and file servers are more efficient with larger RAM for disk caches.
- Has your system been hacked? A system can suddenly become unresponsive because it's running unexpected malware. This is not common on Linux machines, but a system with many users (like a college or business network) is vulnerable to a brute-force password attack.
The next question to ask is: How do I measure usage? Knowing how a system is being used will lead you to the questions, but may not lead you to the answer. A fileserver will cache commonly accessed files in the memory, so one with too little memory may be disk/RAM limited rather than network limited.
Linux has tools for analyzing a system. Many have been discussed in Chapter 8, The Old-Boy Network, Chapter 9, Put on The Monitor's Cap, and Chapter 11, Tracing The Clues. This chapter will introduce more monitoring tools.
Here is a list of subsystems and tools to examine them. Many (but not all) of these tools have been discussed in this book.
- CPU: top, dstat, perf, ps, mpstat, strace, ltrace
- Network: netstat, ss, iotop, ip, iptraf, nicstat, ethtool, lsof
- Disk: ftrace, iostat, dstat, blktrace
- RAM: top, dstat, perf, vmstat, swapon
Many of these tools are part of a standard Linux distribution. The others can be loaded with your package manager.