Virtualization Rocks!
How-To Setup Virtual Machines for Best Performance
JD P
http://blog.jdpfu.com - jdp [at] algoloma
Covering Tonight
- Will not Virtualization Terms
- Will not Cover Installation
- Will not Cover Intro to Virtualization
- Will not Reasons to Virtualize
- General Ideas to get Best Performance
- Settings for best performance
I Lied - Overview

[1] http://www.virtuatopia.com
Actual HW doesn't matter much. Each clientOS only sees virtual hardware.
VirtualBox
- Great for Desktops - with the right settings
- Not so great when stability is required
- Not so great for multiple servers - better options exist
- Add-on program; Not part of the Linux kernel
- Oracle owned ....
Performance Settings
- vCPU
- vRAM
- Display RAM/Settigns
- Storage
- Networking
Most can be changed later, so don't worry too much (*)
vCPU
- Never more than you need. 1 is usually the correct answer
- Never more than you have in the physical machine minus 1
- ACPI and AHCI enabled - better sharing of resources and hot swap
- MS-Windows guests may wish to install w/2 vCPUs, then reduce
RAM
- 512MB for most servers; 1GB for most desktops;
- 1GB for HostOS - Always leave the suggested amount unused
- Adjust the RAM allocated after installation to avoid swapping
Storage
- VirtIO is best, recent Linux
- SATA Controller for Windows (XP needs driver)
- SSD = Sparse allocation fine.
- Spinning HDDs = Fully Pre-Allocated - most important
- Direct hardware storage or network storage for enterprises
- Allocate only what you need. No Large files! 10G-15G for Linux Desktops
Storage Performance
Installation times where crazy different.
* QCOW vHDD - 50 min
* VDI Fully Allocated vHDD - 12 min
* VDI Sparse - no 3D Accel - 14 min
Login:
* QCOW vHDD - 20 sec
* VDI Fully Allocated vHDD - 12 sec
* Prealloc + 3D accel - 10 sec
* VDI Sparse + 3D Accel - 12 sec
* VDI Sparse - no 3D Accel - 13 sec
* VDI Sparse w/Guest Adds - no 3D Accel - 11 sec
* VDI Sparse w/Guest Adds + 3D Accel - 9 sec
Launch firefox:
* QCOW vHDD - 23 sec
* VDI Fully Allocated vHDD - 8 sec
* Prealloc + 3D accel - 6 sec
* VDI Sparse - no 3D accel - 10 sec
* VDI Sparse w/Guest Adds - no 3D Accel - 10 sec
* VDI Sparse w/Guest Adds + 3D Accel - 7 sec
Network Adapters
- Bridged or NAT?
- VirtIO is best, recent Linux
- Intel PRO/1000 for Vista and newer
- No matter what actual HW is; be aware of driver issues (WinXP)
- 1 to 4 NICs supported
Display Integration
- 2D/3D accel
- Enable for Windows
- Disable for Linux (initially)
- Video RAM - 128MB for desktops
- Video RAM - 9MB for servers
Guest Additions
- Help performance
- Windows is easy. setup.exe from a menu - next, next, next ...
- Linux a little harder - dependencies, mounting, manually run setup
- New Vbox or Kernel mean the Guest Additions need to be relinked
See
for dependency instructions.
Remote Access
- Built-in for VirtualBox
- Need a VPN for security with VNC, RDP
- ClientOS methods work (VNC, RDP, NX, ssh ...)
virt-manager - KVM and others (Xen, LXC, ...)
- Requires HW CPU support for virtualization; BIOS VT-x and VMX (check your CPU)
- Competition to VirtualBox (100% F/LOSS)
- Part of the Linux Kernel
- Better for Servers, IMHO
- Extremely Stable
- Remote Control over multiple VMs (ssh channel)
- More features including Live Migration and more control over many VM details
Performance Settings
- Similar to VirtualBox - disk, network, vCPUs.
- Use virtIO for Storage and Networking of Linux guests
- Use SATA and Intel PRO/1000 for Windows
- vCPU Advanced Settings - CPU models, specific features, pinning
- Storage Advanced Settings - disable Cache mode, always pre-allocate on spinning HDDs
- Avoid User-Mode network bridges
Desktop Integration
- VNC is built-in and most used on LAN
- Spice promises near-native performance local and over the network; Never worked for me (hint: a talk on this would be nice)
- ClientOS remote access tools work fine too
- No desktop additions to load; loose desktop integration
Remote Access
- VNC
- Need a VPN for security with VNC, RDP
- I use NX (freenx server and NoMachine NX clients ) Linux, Mac, Windows, Solaris
- FreeNX Server install has manual steps; google for your distro
- NeatX was buggy for me
Summary
- Enable ACPI and AHCI
- Spinning HDDs, pre-allocate entire virtual disk.
- SSDs, sparse is fine
- Keep large files outside VM
- Never allocate more CPUs or RAM than you should. 1 vCPU default
- Leave 1GB of RAM for the HostOS.
- Use the VirtIO drivers for Storage and Networking.
- Windows guests, use the SATA (storage) and Intel PRO/1000 (network)
- Desktop VMs - 128MB of display vRAM
- Server VMs - 9MB of display vRAM
- Avoid 2D and 3D accel settings on Linux
For more details: http://blog.jdpfu.com/2012/09/14/solution-for-slow-ubuntu-in-virtualbox
Questions?
BTW, this entire presenation was performed using a VM running on a private KVM cloud over NX.
Thanks!
Slides at: