Learn vSphere Distributed Resource Scheduler (DRS)

 

VMware vSphere Distributed Resource Scheduler (DRS) is a feature that enables a virtual environment to automatically balance itself across your ESX hosts in a cluster in an effort to eliminate resource contention. The goals of DRS are:

 

at startup, DRS attempts to place each VM on the host that is best suited to run that virtual machine.

while a VM is running, DRS seeks to provide that VM with the required hardware resources while minimizing the amount of contention for those resources in an effort to maintain balanced utilization levels.

If a DRS cluster becomes unbalanced, DRS can migrate VMs from overutilized ESXi hosts to underutilized hosts. DRS performs these migrations of VMs across hosts in the cluster without any downtime by using vMotion. You can determine whether DRS will just display migration recommendations or automatically perform the migration when the cluster becomes unbalanced by defining the automation level.

 

vSphere Distributed Resource Scheduler (DRS) requirements

Before using vSphere DRS, the following requirements must be met:

 

vCenter Server needs to be installed.

CPUs in ESXi hosts must be compatible.

to use DRS for load balancing, hosts in the DRS cluster must be part of a vMotion migration network.

all hosts should use shared storage, with volumes accessible by all hosts.

shared storage needs to be large enough to store all virtual disks for the VM.

DRS works best if the VMs meet vSphere vMotion requirements

 

vMotion requirements

Before performing a vSphere vMotion migration, ensure that the following conditions are met:

 

VM requirements

 

the VM must not have a connection to an internal standard switch.

the VM must not be connected to any device physically available to only one ESXi host, such as disk storage, CD/DVD drives, floppy drives, and serial ports.

the VM must not have a CPU affinity configured.

the VM must have all disk, configuration, log, and NVRAM files stored on a datastore accessible from both ESXi hosts.

if the VM uses RDM, the destination ESXi host must be able to access it.

Host requirements

 

shared storage is required. VM files on a VMFS or NFS datastore need to be accessible by both the source and destination ESXi host.

at least a Gigabit Ethernet network interface card with a VMkernel port enabled for vMotion on each ESXi host is required.

identically named virtual machine port groups connected to the same network. All port groups to which the VM is attached must exist on both ESXi hosts. Note that the port group naming is case sensitive.

CPUs in both ESXi hosts must be compatible. CPUs need to be from the same vendor (AMD or Intel, for example), CPU family, and must support the same features. Note that some features CPU features can be hidden by using compatibility masks.

 

Set DRS automation level

You can determine whether DRS will just display migration recommendations or automatically perform the migration when the cluster becomes unbalanced by defining the automation level. DRS makes these decisions on VM placement when a VM is powered on and when VMs must be rebalanced across hosts in the DRS clusters. Three automation levels are available:

 

Manual – when a virtual machine is powered on, DRS will display a list of recommended hosts on which you can place the VM. If the DRS cluster becomes unbalanced, DRS will display recommendations for VM migration.

Partially Automated – when a VM is powered on, DRS will place it on the best-suited host, without prompting the user. If the DRS cluster becomes unbalanced, DRS will display recommendations for VM migration.

Fully Automated – when a VM is powered on, DRS will place it on the best-suited host, without prompting the user. If the DRS cluster becomes unbalanced, DRS will automatically migrate VMs from overutilized hosts to underutilized hosts.

The Migration Threshold slider bar determines how aggressively DRS select to migrate VMs. For the Fully Automated level, five options are available:

 

Level 1 (Conservative) – apply only priority 1 recommendations. vCenter Server applies only recommendations that must be taken to satisfy cluster constraints like affinity rules and host maintenance.

Level 2 – apply priority 1 and priority 2 recommendations. vCenter Server applies recommendations that promise a significant improvement to the cluster’s load balance.

Level 3 – apply priority 1, priority 2, and priority 3 recommendations. vCenter Server applies recommendations that promise at least good improvement to the cluster’s load balance. This is the default value.

Level 4 – apply priority 1, priority 2, priority 3, and priority 4 recommendations. vCenter Server applies recommendations that promise even a moderate improvement to the cluster’s load balance.

Level 5 (Aggressive) – apply all recommendations. vCenter Server applies recommendations that promise even a slight improvement to the cluster’s load balance.

 

 

DRS affinity rules

DRS affinity rules are used in DRS clusters to control the placement of virtual machines. Three types of rules are available:

 

affinity rules – DRS will try to keep certain VMs together on the same host. These rules are often used in multi-virtual machine systems to localize the traffic between virtual machines.

anti-affinity rules – DRS will try to keep certain VMs are not on the same host. These rules are often used to keep the VMs separated for availability reasons.

VM to host rules – specify whether VMs can or can’t be run on a host. They can be preferential or required. These rules are used in conjunction with DRS groups for ease of administration. A DRS group can either consist of one or more VMs or one or more ESXi hosts.

 

The VM to host DRS rules can either be preferential or required. A preferential rule is softly enforced and can be violated if necessary, for example to ensure the proper functioning of DRS, HA, or DPM. Consider the following example (image source: VMware):

 

drs preferential rules

 

As you can see from the picture above, we have created two DRS groups for virtual machines (Group A and Group B) and two DRS groups for ESXi hosts (Blade Chassis A and Blade Chassis B).

 

The goal of this design is to force the virtual machines in Group A to run on the hosts in Blade Chassis A and to force the VMs in Group B to run on the hosts in Blade Chassis B. But if the hosts in Blade Chassis A fail, the VMs from Group A will be moved to hosts in Blade Chassis B.

 

 

Required DRS rules

The VM to host DRS rules can either be preferential or required. A required rule is stricty enforced and can never be violated, unlike a preferential rule. Required rules are often used to enforce host-based licensing. For example, if the software that is running in your virtual machines has licensing restrictions, you can use a required rule to run those VMs only on hosts that have the required licenses.

 

Here is an example (image source: VMware):

 

 

 

drs required rules

 

 

In the picture above you can see that we’ve created a DRS group for virtual machines named Group A and a DRS group for hosts named ISV-Licensed. The goal of this design is to force the VMs from Group A to run only on hosts in the ISV-Licensed DRS group because these hosts have the required licenses. But if the hosts in the ISV-Licensed group fail, VMs from Group A will not be moved to other host DRS groups.

 

Required DRS rules

The VM to host DRS rules can either be preferential or required. A required rule is stricty enforced and can never be violated, unlike a preferential rule. Required rules are often used to enforce host-based licensing. For example, if the software that is running in your virtual machines has licensing restrictions, you can use a required rule to run those VMs only on hosts that have the required licenses.

Here is an example (image source: VMware):

In the picture above you can see that we’ve created a DRS group for virtual machines named Group A and a DRS group for hosts named ISV-Licensed. The goal of this design is to force the VMs from Group A to run only on hosts in the ISV-Licensed DRS group because these hosts have the required licenses. But if the hosts in the ISV-Licensed group fail, VMs from Group A will not be moved to other host DRS groups.

 

 

 

 

 

Enable DRS

vSphere Distributed Resource Scheduler (DRS) is a feature that enables a virtual environment to automatically balance itself across your ESX host servers in a cluster in an effort to eliminate resource contention. Here are the steps to enable DRS on a cluster using vSphere Web Client:

  1. Select your cluster from the inventory, go to Manage > Settings > vSphere DRS, and click the Editbutton on the right:
  2. TheEdit Cluster Settingswindow opens. Select vSphere DRS on the left and check the Turn ON vSphere DRScheckbox:
  3. Expand the DRS Automationoption. You can set the automation level and determine how aggressively DRS will select to migrate VMs:
  4. Click OKto enable DRS.

To verify DRS functionality, go to the Summary page of your cluster. You should see the vSphere DRS panel:

Notice that the gauge shows that the cluster is imbalanced. To display DRS recommendations, go to Monitor > vSphere DRS:

As you can see in the picture above, DRS recommends to migrate the virtual machine to another host.

 

 

 

Create DRS anti-affinity rule

DRS anti-affinity rules are used in DRS clusters to keep certain VMs on separate ESXi hosts. You can create them using vSphere Web Client:

  1. Select the cluster from the inventory, go to Manage > Settings > DRS Rules, and click the Addbutton:
  2. The Create DRS Rulewindow opens. Enter the name for the rule and choose the rule type. In this example, we will create a rule that will keep two VMs on separate hosts. Click Addto add the VMs:
  3. Select the VMs you would like to run on different hosts and click OK:
  4. Click OKto create the rule.

To test the rule, select your DRS cluster from the inventory and go to Monitor > vSphere DRS. Because the VMs we’ve selected during the rule creation are running on the same ESXi host, DRS recommends to run them on different hosts:

 

 

 

Create DRS affinity rule

The DRS affinity rules are used in DRS clusters to keep certain virtual machines together on the same ESXi host. You can create these rules using vSphere Web Client:

  1. Select your cluster from the inventory, go to Manage > Settings > DRS Rules, and click the Addbutton:
  2. The Create DRS Rulewindow opens. Enter the name for the rule and choose the rule type. In this example, we will create a rule that will keep two VMs on the same host. ClickAdd to add the VMs:
  3. Select the VMs you would like to run on the same host and click OK:
  4. Click OKto create the rule.

To test the rule, select your DRS cluster from the inventory and go to Monitor > vSphere DRS. Because the VMs we’ve selected during the rule creation are running on different ESXi hosts, DRS recommends to run them on the same host:

 

 

 

Create DRS anti-affinity rule

DRS anti-affinity rules are used in DRS clusters to keep certain VMs on separate ESXi hosts. You can create them using vSphere Web Client:

  1. Select the cluster from the inventory, go to Manage > Settings > DRS Rules, and click the Addbutton:
  2. The Create DRS Rulewindow opens. Enter the name for the rule and choose the rule type. In this example, we will create a rule that will keep two VMs on separate hosts. Click Addto add the VMs:
  3. Select the VMs you would like to run on different hosts and click OK:
  4. Click OKto create the rule.

To test the rule, select your DRS cluster from the inventory and go to Monitor > vSphere DRS. Because the VMs we’ve selected during the rule creation are running on the same ESXi host, DRS recommends to run them on different hosts:

 

 

 

 

Create VM to host rule

DRS VM to host rules are used in DRS clusters to specify whether VMs can or can’t be run on a host. These rules are used in conjunction with DRS groups for ease of administration. A DRS group can either consist of one or more VMs or one or more ESXi hosts.

You can create DRS groups using vSphere Web Client:

  1. Select the DRS cluster in the inventory, go to Manage > Settings > DRS Groups, and click the Addbutton:
  2. The Create DRS Groupwindow opens. First we will create a VM DRS group. Enter the name for the group, selectVM DRS Groupas the group type, and click the Add button:
  3. Select one or more VMs and click OK:
  4. Click OKto create the group.
  5. Next, we need to create a Host DRS group. In the DRS Groupspanel, click Add:
  6. Type the name for the group, select Host DRS Groupas the group type, and click the Addbutton:
  7. Select one or more ESXi hosts and click OK:
  8. Click OKto create the group.

After you’ve created DRS groups, you can create a VM to host rule using vSphere Web Client:

  1. Select your cluster from the inventory, go to Manage > Settings > DRS Rules, and click the Addbutton:
  2. The Create DRS Rulewindow opens. Type the name for the rule and choose the rule type. In this example, we will create a rule that will keep a VM on a specific host, so select the Virtual Machines to Hoststype. We will also select the DRS VM Group and the DRS Host Group we’ve created in the previous step and select the Must run on hosts in group option:

The rule we’ve created will force the VM from the group VM DRS Example Group (Linux-VM) to run on the host from the Host DRS Example Group (192.168.5.116). We can test this by selecting our cluster and going to Monitor > vSphere DRS. Because our VM is currently running on a different host, DRS will recommend to migrate Linux-VM to192.168.5.116:

 

Add a Comment

Your email address will not be published. Required fields are marked *