Home > Free Tools, VMware > Web Server Load balancing with VMRUN Utility

Web Server Load balancing with VMRUN Utility

Recently , we had a requirement for automatic web server provisioning and load balancing in our environment . We use a Hardware Load balancer and the Web Servers are hosted on a VMware HA Cluster .  Optimizing the resource utilization is one of the main driving factors for this requirement since there are a lot of seasonal applications that would receive a huge load only during certain period of time like for example a payroll application which would see a huge load during the first five days of a month after which single server would be enough to take the load .

Automatic provisioning and load balancing would mean that we needed to have a tight integration between the load balancer and VMware . While we are working on achieving complete automation on provisioning and load balancing with the load balancer vendor , we set in place a temporary solution for the automatic load balancing using VMware VMRUN utility and VMware vCenter Alarm Actions.

What is VMRUN Utility ?

The vmrun utility runs on any VMware platform with VIX libraries installed, including VMware Workstation, VMware Fusion, ESX/ESXi Hosts,vCenter Server and VMware Server .We can use the vmrun command‐line utility to control specific virtual machines, or teams of virtual machines.We can use VMRUN to perform various tasks on virtual machines as specified below :

  • Power commands
  • Snapshot Commands
  • Record and Replay Commands
  • Guest OS Commands
  • Maintenance Commands
  • VProbes Commands

As a temporary workaround we installed and configured the web application on 5 different VMs and added them as part of the Web Server Pool in the hardware load balancer and ensured every one of them is working fine . We then powered off  VM2,VM3,VM4 & VM5 as VM1 would be able to take the non-peak load . Download and install VMware VIX components in the Virtual Center Server . Now we set out to set vCenter alarm action for VM1 to power on VM2 whenever the CPU utilization exceeded 75% for a continuous period of 5 minutes and similarly for VM2 to power on VM3 , VM3 to power on VM4 and VM4 to power on VM5. On the vCenter alarm action for the VM CPU Utilization , set the alarm action as Run a command and run a simple batch file to invoke VMRUN to power on VM desired ( in this case power on VM2 )  since there is no direct way of powering on VM2 on the vCenter alarm action . Similarly set alaram actions for rest of the Virtual Machines on the web server pool . Shutting down of the Virtual Machines would happen the same way just that we start from shutting down VM5 and come down till VM2 . Again we considered CPU utilization as a criteria for shutting down the Virtual machines.:

Syntax to list registered VMs using VMRUN Utility :

C:\Program Files (x86)\VMware\VMware VIX>vmrun.exe -T esx -h https://IP Address of  VC/sdk -u USERNAME -p PASSWORD listRegisteredVM

Syntax to Power on VM using VMRUN Utility:

vmrun.exe -T esx -h https://IP Address of VC/sdk -u USERNAME -p PASSWORD start “VMX Path of the Virtual Machine”

While we are working on a solution to  automate the entire process , vCenter Alarm actions and VMRUN utility helped us with a temporary workaround . Power of VMware !!

  1. Badri
    September 26, 2010 at 4:12 pm

    Good post and explains the concept in a simple way

  2. Venkatesh Balaji
    October 4, 2010 at 10:34 am

    Good note on elasticity on web layer. Also how to integrate the same in F5 layer and i know the research is ON & try to find the Ans soon 🙂

  3. Karthikeyan Sundaram
    January 23, 2011 at 4:02 pm

    Excellent on automating the process sudharsan.

    I have a question. Instead booting the other vms from OFF to ON; SUSPENDED to ON will save us little more time right ?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: