32 – Performance Tuning
December 5, 2009 – 10:17 pmPlease note… This information no longer exists at the referenced locations. This is only a copy of what was available in 2003.
Basic Linux Training™
Performance Tuning
Henry White
Table of Contents
Hardware
Every system has at least one bottleneck that degrades performance and/or productivity. Most of these can ONLY be dealt with effectively with hardware upgrades.
Generally, the quickest and simplest way to improve performance is to increase memory, bus speed and processor speed. Any of these can give you dramatic results; however increasing bus speed or processor speed will generally be the most expensive – upgrading the microprocessor or motherboard or both.
However, there are many things you can do without upgrading hardware to improve performance.
The general rules for hardware tuning are:
- use the latest version of the firmware for your system, BIOS, disks, adapters, and controllers
- have sufficient memory and swap space to handle the workload
- use high performance storage hardware, including disks, adapters, and controllers
- use different file systems and different disks to balance file I/O
- use high performance network adapters
To achieve efficient disk utilization, you need to create swap partitions on different disk drives.
If your application is network bound, check your network topology and network adapter card settings since they can also affect overall performance. For example, outgoing response packets from a server are usually much larger than incoming request packets. Check the number of network adapters and the network utilization rate to balance network traffic.
Memory and swap space
Swap space is disk space that Linux uses as an extension of its virtual memory. Insufficient memory resources and swap space will cause severe performance problems, especially in a server environment. The following are steps to configure memory and swap space:
- determine how much physical memory your workload requires, especially at peak times
- determine how much swap space you need
- configure the swap space in order to efficiently distribute the disk I/O
Swap space can be either a file or a disk partition. A swap partition is much more efficient, and it offers better performance than a swap file. The general rule of thumb that “swap space should be at least twice as big as the physical memory” goes back to the time when machines were shipped with two to four 1 MB sticks – because it was very expensive (on the order of 20-30 times what it is today; in fact, sticks larger than 8 MB were hard to find, 16 MB and up almost certain to be special order items, and there were no 128 MB or 256 MB manufactured). However, with the price of RAM ridiculously cheap, and the size of new hard drives in the tens of GB, ‘wasting’ 128 MB or more for a swap partition is really not that big a deal. (BTW, many sysadmins routinely carve out an 128 MB swap partition on each hard drive.)
Kernel
Linux daemon processes are started by the init process at boot time. init will launch other processes, which in turn could become parents to others called child processes. When a process launches another process, it uses the Fork system call to create the new process. In a heavily loaded system with multi-user support, there may be thousands of processes running at a given time. As a result, you need to efficiently control and allocate resources to achieve optimum performance.
You can control which processes are run at boot time by configuring /etc/inittab.
Do you need all of those services?
Disable all unused services and daemons, especially network related services since every open service requires system resources like file descriptors, memory, etc. To disable a service, you need to comment out (by using #) the service name in the /etc/inetd.conf file. The following services may have been installed and enabled by default:
- FTP
- Telnet
- Gopher
- remote shell (rsh)
- remote login (rlogin)
- remote exec (rexec)
- talk, ntalk
- POP2, POP3, IMAP
- finger
- time (tcp), time (udp)
- auth (ident)
You need to restart inetd services after modifying /etc/inetd.conf.
You should remove all unused applications like multimedia, scripting languages, file editor, server software such as Samba, NFS, NIS, etc.
Assignments
The Linux /proc filesystem (also called the Linux process filesystem) provides a lot of information about the Linux kernel and the processes currently running on your system. /proc is used as an interface to kernel data structures, and some files allow kernel variables to be changed as well. Most of the files are readable using the cat or more command to view their contents.
To control processes that are competing for CPU resources, you may lower the priorities of non-critical tasks and daemons using nice or snice. Linux has two priority numbers associated with each process: PRI and NI. The PRIority is the actual process priority which is dynamically computed by Linux. The other is NIce (the requested process execution priority number) which can be set by you or ‘root’ to influence the PRI number. The valid range of the process priority is from -20 (highest priority) to 19 (lowest). (Only the ‘root’ can increase a process priority.)
Linux provides a tool called hdparm to get and set hard disk drive parameters like filesystem read ahead count, drive look ahead, drive write cache, drive multi-sector access, and drive look ahead prefetch count. Use extreme caution and keep notes if you use this because you can quickly and easily FUBAR your system if you’re unfamiliar with it.
Files and Directories
- /proc/
- /proc/cpuinfo
- /proc/dma
- /proc/interrupts
- /proc/ioports
- /proc/meminfo
- /proc/partitions
- /proc/pci
- /proc/swaps
- /proc/sys
- /proc/version
Tools and Utilities
- hdparm
- mkswap
- netstat
- nice
- ps
- swapon
- top
- vmstat
Online:
- http://linuxperf.nl.linux.org/ – Linux Performance Tuning
- http;//www.tunelinux.com/ – optimization
- http://www.portico.org/ – linux tips
Copyright © 1997-2003 Henry White. All Rights Reserved.
Reproduction or redistribution without prior written consent is strictly prohibited. Address comments and inquiries to info@basiclinux.net.
Sorry, comments for this entry are closed at this time.