 |

Tweaks and Hints
- Kernel bloat: Every device driver loaded into the kernel takes up space in RAM. Most Linux distributions use loadable modules, but some may be loaded that aren't needed (such as parallel port drivers). Run lsmod or look at /proc/modules to see what modules are loaded, as well as those that are in use. Then think about which of these drivers are really needed. If you compile your own kernels, don't compile unneeded drivers.
- Resource limits: There are global and per-user imposed resource limits. A good rule of thumb is 256 open files for every 4 MB of RAM. There is a similar inode maximum (these are inode data structures, not inodes on a disk) that should be roughly four times the max open files. If you are seeing errors in your error log mentioning failure to allocate (or grow) more inodes or if the file-max limit has been reached, try echo 16384 > /proc/sys/fs/file-max or echo 65536 > /proc/sys/fs/inode-max. The max value (for the Intel IA32 architecture) is 231 - 1, or 2,147,483,647. These changes must be executed at every boot. A likely place to put them is the start-up script rc.local, in /etc.
- Tracking CPU usage: Using the tool vmstat, you can pinpoint various application processing problems. Look at the us field of vmstat's output. If it is high, then a high percentage of the system CPU is being used by a process doing computation. Use top to figure out which process is using so much of the CPU. If the sys field in vmstat is high (relative to baseline), then CPU time is being spent by the kernel itself. Typically, if both sys and us are high relative to your baseline, your system is overloaded.
- Tracking disk usage: Using the vmstat tool, you can monitor the blocks moving in and out of the disk system by monitoring the bi and bo fields. If they increase relative to the baselines, the disks are working harder. Seeking is a problem where many files are opened, read or written to, and closed again and again. To determine if seeks are a problem, know your disk's seek time and use it to compute the total TPS (transactions per second) that your disk is capable of. Then use the iostat tool to find out the actual TPS.
- Tracking network usage: Use iptraf to monitor network interfaces. Use ifconfig to see any errors at the data link level. When debugging traffic problems or misbehaving clients and servers, a packet sniffer called ethereal (and its command-line variant tethereal) is essential for generating packet captures, breaking down protocols and sorting packets by type, and it can import and export multiple capture file formats.
- Tracking RAM usage: The command free (or reading from /proc/meminfo) gives the status of memory in use, free or used as file buffers. Use vmstat and observe the si and so values to determine the rate at which data is being paged into and out of swap. A high rate compared with the baseline indicates insufficient RAM.
- Unwanted services: Look at the output of ps -auxwww and identify all the processes. Any services running that you know you didn't start were probably started at boot time. Check the /etc/rc.* files and directories. Depending on your distribution, you may be able to use a run-level editor to control what starts at boot.
|
 |