In the early days of virtualization, the performance gap between an application running on a physical server and...
an application running in a VM was as high as 10%. With the help of some best practices, VMware's virtualization stack has reduced this number to 2%, improving overall efficiency. In fact, VMware has best practices for just about everything, including deployment, VM creation and optimization, which physical hardware and virtual machine hardware to use and which hardware version your VMs should use.
This last item is especially important because which VM hardware version you use on your physical host server determines what that particular VM carries as a disk controller, whether it has virtual 3D graphics acceleration, whether the VM has USB ports and which VM functions it supports. Let's review VMware's guidelines for getting the best performance out of your virtual machine hardware.
Use the default template
Depending on which OS you want to install, make sure you've selected the correct template, as VMware optimizes these templates. The OS installation wizard will automatically choose the correct set of components for the VM. VSphere 6.5 uses VM hardware version 13, which is the latest version.
Each new version of vSphere includes improvements and new features, which you can apply to your VMs by choosing the appropriate hardware version. If, however, you run a mixed environment -- with, let's say, some ESXi 6.5 and some ESXi 5.5 hosts -- your hardware version should be compatible with the oldest ESXi host in your environment. Otherwise, the VM with newer hardware won't be able to run on an older host. I advise against upgrading your hardware to the latest ESXi version simply because you need to use a specific feature.
Use only the components you need
You should check to see whether you really need all of the hardware components your VM carries. Does your VM really need a virtual CD-ROM, virtual mouse or parallel and serial ports? If not, it's best to remove them. This will optimize the VM so that it uses less memory and fewer CPU cycles from the underlying ESXi host, which will, in turn, help you achieve higher consolidation ratios.
You can take optimization a step further by deactivating the floppy disk or CD-ROM within the guest OS's basic input/output system (BIOS). To do so, start the VM, and press F2 to enter setup. Locate the Advanced tab, and select I/O Device Configuration > Floppy Disk Controller. From there, use the plus and minus keys on your keyboard to change the value, and disable the floppy disk controller. Save this as a template, and use it within your infrastructure as an optimized template.
Choose a virtual network adapter type
You can choose the best virtual network adapter type for your VM. Some older legacy adapters have been replaced over time, and it's wise to update your adapter to reflect that. For example, VMXNET Generation 3 (VMXNET3) is the latest paravirtualized adapter with multi-queue support, IPv6 offloads and MSI/MSI-X delivery interruption, which uses an alternative in-band method to signal interruption. VMXNET3 added support for jumbo frames and hardware offloads. The most common virtual network adapters are VMXNET3 and E1000e.
Always use the latest version of VMware Tools
VMware Tools is a suite of device drivers and utilities that enhance the performance of the guest OS and improve VM management. Although a guest OS can run without VMware Tools, it'll lose out on important functionality and convenience. Be sure to update VMware Tools after an ESXi upgrade. VMware Tools includes the balloon driver responsible for memory reclamation in ESXi, so you can't use ballooning without it. VMware Tools also plays an important role in VM memory allocation; you can't overcommit memory without it.
Use Paravirtual SCSI storage drivers
For a long time, the SCSI driver was the default for storage, but VMware has since replaced this with a paravirtual driver that allows for CPU usage and higher I/O throughput. Whether your VM uses the SCSI driver or the paravirtual driver depends on which OS it runs.
Some OSes require you to install a driver, first. If this is the case and you need to change to storage controller on boot disks, fear not: There's an easy way to change the controller for the data disk, which triggers installation for the storage controller driver on the Windows system.
Use ESXi-supported guest OSes
VMware supports a wide variety of guest OSes, all of which you can view with VMware's online Compatibility Guide. You'll need a supported 64-bit CPU in the host computer in order to install and run a 64-bit guest OS, but this is standard for most modern CPUs.
Optimize VMs and guest OSes
So far, we've covered how to optimize your virtual machine hardware; now, let's take a look at how to optimize each VM. One way to optimize a VM is to disable screensavers and Windows animations. If you run Linux VMs, don't use the X server unless it's absolutely necessary. Things like screensavers and X servers can affect host performance and penalize other VMs on the same host if you try to achieve high consolidation ratios.
You might even want to try using a tool to optimize your guest OS. For example, the VMware OS Optimization Tool helps optimize Windows 7, 8, 2008, 2010 and 2012 systems for use with VMware Horizon View. This tool can also stop unnecessary services through the use of built-in templates.
Another way to optimize is to run backups and virus scanners during off-peak hours. You should also avoid scheduling those tasks simultaneously. You can space backup jobs throughout the whole backup window, where you can directly schedule jobs as needed.
Don't use snapshots in production
Snapshots are a great tool to use before an upgrade or configuration change, but you should only use them on a temporary basis and immediately remove them once you're finished. Leftover snapshots are a huge waste of disk space and can seriously slow down a VM's performance because the VM runs off the delta disk created by the snapshot rather than the full VMDK.
Limit the number of vCPUs in your VMs
If you use single-threaded applications or applications that aren't designed for multithreading and parallelism, it doesn't make sense to use multiple virtual CPUs (vCPUs).
The VMware ESXi CPU scheduler allocates physical CPU time slots to vCPUs in VMs. If your VMs are configured with multiple vCPUs, the CPU scheduler must wait for physical CPUs to become available. Unused vCPUs will continue to consume system resources even when the system isn't using them. If other single-vCPU VMs use the system, your multi-vCPU VM will have to wait for CPU time.
VM configuration is one of the most important design decisions you can make in your environment. Apply these VMware best practices, and choose the right components to optimize your virtual machine hardware and improve overall infrastructure performance. Keep in mind, though, that how you optimize each VM or application depends on its requirements; there's no one-size-fits-all master VM template that you can apply to every workload.