IBM Cloud Global

 View Only

Achieving High Availability: Load Balancing Techniques for Classic VMs in IBM Cloud

By Gunasekaran Venkatesan posted Tue May 16, 2023 03:09 PM


In today's dynamic cloud environment, load balancing is crucial for ensuring optimal performance, scalability, and availability of applications. IBM Cloud provides a powerful infrastructure for managing virtual machines (VMs) and offers seamless load balancing capabilities. In this blog post, we will walk you through the step-by-step process of setting up and configuring load balancing for Classic VMs in IBM Cloud. By the end, you will have a clear understanding of how to create a load balancer and achieve efficient distribution of traffic across multiple VM instances.

Step 1: Logging into the IBM Cloud Portal

To begin the process of setting up a load balancer using VM instances on the IBM Cloud platform, you need to log in to the IBM Cloud portal. Here's a step-by-step guide on how to do it:

1. Open your preferred web browser and navigate to the IBM Cloud portal website. The URL is "".
2.On the IBM Cloud homepage, locate and click on the "Get started with IBM Cloud" or "Try IBM Cloud for free" button. This action will redirect you to the IBM Cloud account creation page
3. On the account creation page, you will be prompted to provide the necessary information to create your free trial account. Fill in all the required fields, including your email address, password, and any other requested details.

By following these steps and creating a free trial account on IBM Cloud, you will have the necessary credentials to log in to the IBM Cloud portal and proceed with the remaining steps for setting up your load balancer using VM instances.

Step 2: Provisioning VM Instance

  1. Once logged in, you will be directed to the IBM Cloud dashboard. Look for the navigation menu on the left side of the page and find the "Classic infrastructure" section.

  2. Under the "Classic infrastructure" section, locate and click on the "Devices List" option. This will take you to the page where you can manage and view your virtual devices.

  3. On the "Devices List" page, you will find a list of your existing VM instances, if any. To create new VM instances, click on the "Order" button, typically located at the top of the page.

  4. In the VM instance creation form, you will have several configuration options. Choose "Ubuntu" as the base image from the available list of operating systems. You can customize the specifications, such as the instance type, CPU, memory, and disk size, based on your requirements.

  5. Fill in the necessary details, including the number of instances you want to create (in this case, two instances).

  6. Review the pricing and billing details associated with the selected configuration. Ensure that the cost aligns with your budget and requirements. Once you have reviewed and confirmed the configuration, click on the "Create" button to initiate the provisioning process.

  7. The VM instances will be provisioned, and you will receive notifications or status updates regarding the progress. The time taken for provisioning may vary based on the configuration and system load.

  8. Once the provisioning process is complete, you will be able to view and manage your newly created VM instances in the "Devices List" section.

Step 3: Logging into Server 1:

  1. Once the VM instances are provisioned, Copy the public IP address under network details where you can see in the VM overview tab.
  2. Open a terminal or command prompt and log in to "Server 1" using SSH with the following command:

    ssh root@<vm_public_ip_address>

  3. If the provided password is correct, the SSH connection will be established, and you will be logged in to "Server 1" as the root user. You will see a command prompt indicating a successful connection.

Step 4: Installing Apache Web Server

  1. Update the package lists and upgrade the existing packages by running the following command
    sudo apt update && sudo apt -y upgrade

  2. Install the Apache web server using the following command:

    sudo apt install -y apache2
  3. Verify if Apache is running properly by executing the following command:
    sudo systemctl status apache2

Step 7: Editing the HTML File

  1. Open the index.html file located at /var/www/html/ and make desired modifications to customize the web page
    <!DOCTYPE html>
        <title>Welcome to IBM Cloud VM1</title>
            /* CSS for animation */
            @keyframes slide-in {
                from { opacity: 0; transform: translateY(-50px); }
                to { opacity: 1; transform: translateY(0); }
            /* CSS for background color */
            body {
                background-color: #f2f2f2;
            /* CSS for heading */
            h1 {
                text-align: center;
                font-size: 32px;
                color: #333;
                animation: slide-in 1s ease-in-out;
        <h1>Welcome to IBM Cloud VM1</h1>

  2.  Copy the Public IP address of "Server 1" and paste it into a web browser's address bar to see the modified Index.html page

Step 8: Repeating Steps for Server 2

  • Repeat Steps 3 to 7 for "Server 2" to set up the Apache web server and customize the index.html web page. Please change the title "Welcome to IBM cloud VM2"  index.html file to differentiate the server2 from server1.

Step 9: Provisioning the Load Balancer

  1. Navigate to the IBM Cloud portal and provision a load balancer.
  2. Configure the load balancer with public-to-public endpoints and set the load balancer to use the HTTP protocol on port 80.
  3. Ensure to add the two provisioned server instances.
  4. Create the load balancer, ensuring it includes the two server instances. 

Step 11: Testing the Load Balancer

  1. Once the load balancer is provisioned, Copy the loadbalancer address provided.
  2. Access the loadbalancer address in a web browser to test the load balancing functionality. The load balancer should distribute the incoming requests evenly across the two VM instances. As a result, you should see the web page content served alternately from both "Server 1" and "Server 2" instances.
  3. Refresh the web page multiple times or open it in multiple browser tabs simultaneously. Observe that each time you refresh or access the web page, it is served by either "Server 1" or "Server 2" in a round-robin fashion. By performing these tests, you can validate the load balancer's functionality and confirm that it evenly distributes traffic among your VM instances. This ensures high availability and improved performance for your web applications or services.



By following the above steps, we have successfully created a load balancer using virtual machine instances on the IBM Cloud platform. This setup allows for efficient distribution of incoming network traffic across multiple servers, ensuring high availability and improved performance for web applications. Feel free to explore further configurations and enhancements to optimize your load balancing setup as per your specific requirements.          

Simplified load balancing of your business application servers

What is Load Balancing?