XenServer load balancing with XO

Hi everyone! Today, I'll introduce you a new feature of Xen Orchestra: live load balancing of your XenServer VMs.

As usual here, we'll first explore quickly the concept of load balancing, then the problems, and finally our solution.


Starting with Wikipedia:

In computing, load balancing distributes workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units or disk drives.

Short and accurate definition! What about XenServer now?

In virtualization

In the case of virtualization, you have multiple physical hosts, which runs your virtual machines (VMs).

Each host has a limited set of resources: CPU, RAM, network bandwidth etc.

Maybe you already heard about VMWare DRS (Distributed Resource Scheduler): that's the same principle here, but for XenServer.

So the first objective is to adapt your VM placement in live (without service interruption), depending of the load. Let's take a simple example:

These 2 hosts are running 6 VMs:

Let's say both hosts are using only 5% of all their CPUs

Suddenly, one of your VM starts to have a very high CPU load (in yellow): performance of other VMs on this same host could be impacted negatively (in pink):

Host 1 still using 5% of its CPUs, but host 2 is now a 95%.

We are detecting it and now move others VM to the other host, like this:

Host 1 has a slightly increased load, but host 2 can be fully used for the "problematic" VM without disrupting service of other VMs.

This way, the impact of your high load usage on one VM doesn't penalize everyone.

But it's not the only way to see this: there is multiple possibilities to "optimize" your existing resource usage:

  1. maybe you want to spread the VM load on the maximum number of server, to get the most of your hardware? (previous example)
  2. maybe you want to reduce power consumption and migrate your VMs to the minimum number of hosts possible? (and shutdown useless hosts)
  3. or maybe both, depending of your own schedule?

Those ways can be also called modes: "performance" for 1, "density" for number 2 and "mixed" for the last.

In Xen Orchestra

We started to work on the "performance" mode inside Xen Orchestra. Our first objectives were:

  • to provide an easy way to create "plans" to supervise load balancing with simple rules
  • to work only on the host CPU usage
  • to start a detection every 2 minutes
  • to work across various pools
  • to be able to exclude hosts

Creating a plan

Creating a plan is the first step. In our example, we want to create a plan called "perf1", using "performance mode", and acting only on one pool, labelled "Lab Pool":

By default, the CPU threshold is 90%, but it could be set manually (here at 80%):

Let's play!

Here is the initial situation:

4x VMs on 2 hosts, lab1 and lab2

CPU usage on both hosts is very low:

CPU usage on lab1

CPU usage on lab2

Let's trigger a very high CPU load on the VM "Windows Server NFS Share" (using Prime95), which is on lab1:

lab1 starts to work at 100% on all it's CPUs

Both "nfs share" and "Salt Master" VMs will suffer this concurrent CPU usage and won't have enough power to deliver if necessary. And when the average on last 2 minutes hits the threshold (80% here), actions are taken:

lab1 is now working a full speed with the only the VM using all it's CPUs.

Let's check the new CPU load on lab2:

Load is only slightly increased due to 2 new VMs


With this simple but first initial algorithm, we managed to mitigate automatically an issue of VM resource usage. Of course, it works also in cases when you have to really spread the load on all your servers (ie when the sum of all VM usage is higher than the threshold): that's the exact same principle.

You have more than 2 hosts? Again, same idea, it will also work.