loadbalancing

How to create and configure a load balancer

Prerequisites:

Before starting this tutorial, make sure you have 2 (or more) instances running that you want to load balance.

Step 1 - Creating the load balancer pool.

First, go to dashboard.fuga.io and go to Network – Load Balancers.

Make sure the tab 'pools' is selected. You should see something similar to the following screen:

OpenStack loadbalancing

Click on Add pool and fill out the following screen:

Create and configure a load balancer

The fields are as follows:

  • Name: The name for your load balancer. This can be anything you want. Make
    sure it’s something useful and descriptive.
  • Description: A description of this load balancer. Can be anything you want.
  • Provider: The system used in the background to load balance your instances.
    At the time of this writing only haproxy is available.
  • Subnet: Select the subnet you want the load balancer to be able to reach.
    Make sure this is the same subnet your instances are in.
  • Protocol: Either HTTP, HTTPS and TCP are available. Select the value based on
    the application you want to load balance.
  • Load balancing method: 3 load balancing methods are available:
    • Round Robin: Rotates the requests evenly between multiple instances. This
      means it is not guaranteed that a visitor always arrives at the same node. Make
      sure your application can deal with that before selecting this option.
    • Source IP: Requests from the same source IP address are directed to the same
      node whenever possible. because of that, sessions in web applications usually
      work without the need for central session storage.
    • Least connections: Always sends new connection to the node with the least
      active connections. This means it is not guaranteed that a visitor always
      arrives at the same node.
  • Admin state: You usually want this to be UP - Setting this to DOWN will make
    the load balancer unavailable.

After setting all the fields to your desired values, press the Add button. The load balancing pool will now be created.

Step 2: Add members to the load balancer.

After creating the load balancer, go to the Members tab. You should see a screen similar to this one:

Load balancer members

Click on the Add Member button and fill out the following screen:

Load balancer add member

The fields are as follows:

  • Pool: The load balancer pool to be used. In this case the pool you created in step 1.
  • Member source: The way you want to select what instance(s) to add to the pool. Either select from a list of available instances or add nodes by IP Address.
  • Member(s): When using the member source 'select from active instances' this will produce a list of available instances that you can select one or multiple instances.
  • Weight: This value determines the ratio that this and other members will serve the requests.
  • Protocol Port: The port the service is available on the pool member.
  • Admin state: You usually want this to be UP - Setting this to DOWN will make this pool member unavailable for the load balancer.

After setting all the fields to your desired values, press the Add button. The members will now be added to the pool.

Step 3: Creating a monitor.

Most likely you'll want the load balancers to automatically disable nodes that are having problems. To do this, we'll create a new monitor.

Start by going to the Monitors tab. You should get a screen like this:

Load balancer monitors

Click on the Add monitor button and fill out the following screen:

Load balancer add monitor

The fields are as follows:

  • Type: There are 4 options to choose from:
    • PING: this does a basic ping request to the server. If it
      responds the node is considered to be available.
    • HTTP(S): With this you'll be able to do a simple web request to any URL you want. By looking at the HTTP Status code the check determines if the node is alive or not. By creating a special monitoring page you'll be able to do your own checks to see if the node is in working order or not and return the correct HTTP Status code.
    • TCP: This creates a simple connection attempt to the node's port as configured in step 2. If the connection is created the node is considered alive.
  • Delay: The time in seconds between alive checks.
  • Timeout: The time to wait for a response/connection/ping reply before the check is considered to fail.
  • Max retries: The number of retries before the node is considered truly to be
    offline (Admin state will be set to DOWN).
  • Admin state: As always set this to UP.

After setting all the fields to your desired values, press the Add button. The monitor will now be created.

Next, we'll need to associate the monitor. Go back to the 'Pools' tab and press the
downward arrow next to 'Edit Pool'.

Next, click on the 'Associate monitor' button. You'll get a screen like this:

Load balancer associate monitor

Step 4: Creating a VIP.

To be able to use the actual load balancer, you'll need to create a VIP. A VIP is
a Virtual IP Address.

To do this, go back to the pools tab and click the downward arrow next to 'Edit Pool' and click the 'Add VIP' button:

Add VIP

You'll now see a screen where you can configure the new VIP:

Specify VIP

The fields are as follows:

  • Name: A name to identify the VIP. Can be anything you want.
  • Description: A description of the VIP. Can be anything you want.
  • VIP Subnet: The subnet that the VIP will be created on. Set this to the same network as the connecting nodes are in. If this VIP is going to be available from the internet, make sure the subnet is a network connected to the external network using a router. You'll be able to create a floating IP later.
  • IP Address: You can enter a manual IP address or let the system determine which IP address in the subnet to use.
  • Port protocol: The port that the VIP will listen on for requests.
  • Protocol: Can be either HTTP, HTTPS or TCP. Depending on the application it will serve.
  • Session Persistence:
    • No session persistence: Connections won't be in the same session.
    • SOURCE_IP: Connections from the same source IP will be in the same session
    • HTTP_COOKIE: Connections with the same HTTP Cookie will be in the same
      session.
  • Connection limit: The maximum number of connections allowed to this VIP.
  • Admin State: Set this to UP to make the VIP available. If set to DOWN the VIP
    will not be accessible.

Step 5: Adding a Floating IP address.

This step is optional and only needed if you want the load balancer to be accessible externally. If you are making a load balancer for database connectivity you probably don't want to do this.

If you are making a load balancer for web a web frontend though, you'll want to allocate a floating IP address.

To assign a floating IP address, go back to the pools tab and click the downward arrow next to 'Edit Pool' and click on the 'Associate Floating IP' button.

You'll see a screen where you can select an available floating IP. If you don't have a floating IP left, you can request one by pressing the + button next to the IP Address field.

Load balancer manage Floating IP

After entering the required data, press the ‘Associate’ Button. The Floating IP Address will now be assigned to the new load balancing pool.

Was this article helpful?


Next article:

OpenStack storage types

Introduction There are different types of storage in OpenStack: ephemeral storage and persistent volumes. It’s important you understand the difference so you can best determine which type to use. This guide explains the differences between the two. It also describes two varieties of persistent storage you can use. Ephemeral Storage This type of storage is associated with a single unique instance. It exists only as long as the instance itself. It’s generally used for the root file system and operating system of the instance.