Patent ID: 8832683

Claim:
A method, comprising: monitoring, by a host controller machine, metrics collected by the host controller machine, the metrics comprising memory-related metrics of host machines managed by the host controller machine and provided to the host controller machine by hypervisors managing virtual machines (VMs) on each of the host machines; determining, by the host controller machine, that the collected metrics have triggered a load balancing operation managed by the host controller machine, the triggering of the load balancing operation in view of failure of the collected metrics to satisfy configured conditions maintained by the host controller machine; selecting, by the host controller machine in view of memory-related metrics of the host machines, one of the host machines to participate in a migration process as part of the load balancing operation; analyzing, by the host controller machine, memory-related metrics of each of a plurality of VMs hosted by the selected host machine, wherein the memory-related metrics of the host machines and of the VM comprises at least one of an amount of memory utilization, over commit, swap usage, a paging ratio, or memory sharing; and selecting, by the host controller machine in view of the analyzing, a target VM of the plurality of VMs of the selected host machine to migrate from the selected host machine to a different host machine as part of the migration process of the load balancing operation, the selecting the target VM further comprising: selecting one of the VMs from the plurality of VMs that has a highest load balancing score; adjusting the load balancing score for the selected VM in view of at least one of a size of a memory set of the target VM, a paging ratio associated with the target VM as seen by the selected host machine, or a paging ratio experienced by the target VM; adjusting the load balancing score for the selected VM further in view of an amount of shared memory the VM has with the other VMs of the plurality of VMs hosted by the selected host machine; when the selected VM maintains the highest load balancing score among the plurality of VMs subsequent to the adjusting, identifying the selected VM as the target VM; when the selected VM does not have the highest load balancing score among the plurality of VMs subsequent to the adjusting, repeating the selecting the one of the VMs and the adjusting the load balancing score; and detecting and preventing loops of VM migration between the selected host machine and the different host machine.