- 1 VM Performance Tuning Guidelines
- 2 Inside the VM
- 3 Outside the VM (on the host)
- 4 References
VM Performance Tuning Guidelines
I will document some tweaks and tips to increase performance of a Linux or FreeBSD virtual machine. Many tips will likewise apply to physical machines as well, but the focus is on virtual machine technology. Most of my experience is with CentOS-3 and 4 (a Red Hat Enterprise Linux derivative) running on VMware ESX & Server.
Inside the VM
SMP vs. Uniproc
Because a hypervisor already multiplexes cpu cycles to the VMs that need it, there is usually nothing to be gained from configuring SMP within a VM. In fact the addl overhead of SMP can actually slow down a VM. Bottom line: Use uniprocessor
Be sure the virtual machine is configured with at least 256MB of memory.
Add this kernel option to grub configuration in most cases, unless storage is non-local
kernel ... elevator=noop
Install the appropriate kernel. Under Ubuntu it's called linux-virtual
sudo aptitude install linux-virtual
Consider running nscd (name service caching daemon) if there is alot of network activity looking up usernames, groups or hosts (DNS) from a network-location. Otherwise turn it off.
- (Linux) If possible, use a performance-enhanced journaling filesystem such as xfs or jfs, which are faster then ext3.
- For JFS under CentOS you will need the jfsutils package and "centosplus" kernel from "centosplus" repo
- (FreeBSD) enable soft-updates on all filesystems except for /
Use lighttpd or nginx instead of apache. Make sure you aren't loading anything you don't need, mod_perl and php are heavy-hitters. Minimize your use of CGI scripts. For the cost of addl. RAM you can use fastcgi.
Terminal Emulator (xterm et al)
I recommend mrxvt over gnome-terminal or konsole. It has a much lower memory footprint.
(Linux) dash is a shell that uses much less memory than bash. Users have reported freeing up to 12MB of RAM by switching to dash. Apparently dash is the new name for ash.
There is little need to getty to be running on more than a couple of ttys. By removing tty3-tty6 you can save a couple MB of RAM and some tiny amount of processor time.
Comment out the lines (shown below) in /etc/inittab
# Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 #3:2345:respawn:/sbin/mingetty tty3 #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6
Send a SIGHUP to init to re-read the inittab file
kill -HUP 1
Turn off unnecessary services
Much like getty listening to ttys, the default configuration of most Linux distributions is not well suited to performance.
- X windows
- in /etc/inittab... id:3:initdefault:
- xfs - x font server, optional
- gdm - if the inittab tweak above doesn't cut it
Try this command: /sbin/chkconfig --list | grep 3:on Here are some things I tend to turn off in CentOS and Red Hat.
There are plenty more.
Here is a quick sh command to take care of it (using same ones from above). Adjust as necessary.
for svc in isdn pcmcia anacron bluetooth kudzu cpuspeed auditd cups smartd gpm; do /sbin/service $svc stop /sbin/chkconfig $svc off done
If you are not mounting or exporting any NFS shares, these addl. services can be disabled
for svc in portmap nfslock netfs autofs; do /sbin/service $svc stop /sbin/chkconfig $svc off done
Consider either disabling the [x]inetd service or specific services it handles e.g. telnet
Obviously this only applies if VMware is your underlying platform. Enable tools.syncTime="TRUE" if nothing else.
Under ESX, use the vmxnet driver not the pcnet32 (aka vlance). This will require the vmware-tools to be installed.
Turn off selinux - set the following in /etc/selinux/config
Turn off ipv6 - put the following lines in /etc/modprobe.conf (RHEL/CentOS)
alias ipv6 off alias net-pf-10 off
Also make sure this line appears in /etc/sysconfig/network
Outside the VM (on the host)
- Use RAID-10, as it is the fastest storage access possible. Use a decent raid controller with battery backup (BBU).
- (Linux) change the default scheduler (need reference)
- Consider your filesystem type, xfs and jfs are reportedly MUCH faster then ext3
- Never store your VMs on NFS
Only assign what is needed. Consider removing USB, Audio and floppy drives.
- VMware ESX Server guest OS performance tips
- Implementing network security on Centos/RHEL Servers
- VMware Guest Notes
- Jason Rowe's VMware Server Tips’n'Tricks
- FreeBSD on VirtualBox on FreeBSD