Sunday, May 27, 2012

In virtualization, use as few vCPU as possible for optimal CPU performance

Nowadays, virtualizing a physical server into several virtual servers is a common practice. In fact, the Infrastructure-as-a-Service (IaaS) model of Cloud Computing is based on virtualization too.

Unlike physical server running on physical CPU, whereby the common sense is more CPU (or CPU core) is better, in a virtualized environment, it is often a best practice to configure as few virtual CPU (vCPU) as possible to the virtual server.

In most cases, if 1 vCPU is sufficient, it is advisible to configure the virtual server to use 1 vCPU instead of more.

This is because:
  • Each vCPU will consume some physical CPU resource even if it is in idle state.
  • Unused vCPUs still consume timer interrupts unless the guest OS kernel is configured with the NO_HZ "tickless timer" option (a feature available in the latest Linux 2.6 kernel).
  • The more vCPUs a virtual machine has, the more interrupts it requires.
  • Maintaining a consistent memory view among multiple vCPUs can also consume additional resources, both in the guest OS and the host.
  • Some older guest OS execute idle loops on unused vCPUs, thereby consuming
    resources that might otherwise be available for other uses.
  • The guest scheduler might migrate a single-threaded workload amongst multiple vCPUs, thereby
    losing cache locality.
  • In SMP guests the guest OS can migrate processes from one vCPU to another. This migration can incur a small CPU overhead.
In addition, it is a good practice to disable screen savers and Window animations in virtual machines. On Linux, if using an X server is not required, disable it. This is because screen savers, animations, and X servers all consume extra physical CPU resources, potentially affecting consolidation ratios and the performance of other virtual machines.

Reference: Performance Best Prictice for VMWare vSphere 5.0

1 comment:

  1. If using OpenVZ for the virtualization, and the server is using 3.x kernel, better dun use vswap for the vm...
    It is making the vm heavier...
    Hope it will be fixed soon...
    Haih....

    ReplyDelete