Galera Load Balancer

Galera Load Balancer provides simple TCP connection balancing developed with scalability and performance in mind. It draws on Pen for inspiration, but its functionality is limited to only balancing TCP connections.

  • Support for configuring back-end servers at runtime.
  • Support for draning servers.
  • Support for the epoll API for routing performance.
  • Support for multithreaded operations.
  • Optional watchdog module to monitor destinations and adjust the routing table.


Unlike Galera Cluster, there is no binary installation available for Galera Load Balancer. Installing it on your system requires that you build it from source. It is available on GitHub at glb.

To build Galera Load Balancer, complete the following steps:

  1. From a directory convenient to you for source builds, such as /opt, use Git to clone the GitHub repo for Galera Load Balancer.

    $ git clone
  2. Change into the new glb/ directory created by Git, then run the bootstrap script.

    $ cd glb/
    $ ./
  3. Configure Make to build on your system.

    $ ./configure
  4. Build the application with Make.

    $ make
  5. Install the application on your system.

    # make install


    Galera Load Balancer installs in /usr/sbin. You need to run the above command as root.

Galera Load Balancer is now installed on your system. You can launch it from the command-line, using the glbd command.

In addition to the system daemon, you have also installed libglb, a shared library for connection balancing with any Linux applications that use the connect() call from the C Standard Library.

Service Installation

The above installation procedure only installs Galera Load Balancer to be run manually from the command-line. However, you may find it more useful to run this application as a system service.

In the source directory you cloned from GitHub, navigate into the files/ directory. Within this directory there is a configuration file and a service script that you need to copy to their relevant locations.

  • Place into /etc/init.d directory under a service name.

    # cp /etc/init.d/glb
  • Place glbd.cfg into either configuration directory. For Red Hat and its derivatives, this is /etc/sysconfig/glbd.cfg. For Debian and its derivatives, use /etc/default/glbd.cfg.

    # cp glbd.cfg /etc/sysconfig/glbd.cfg


    The glbd.cfg configuration file used below refer to the one you have copied into /etc.

When you finish this, you can manage Galera Load Balancer through the service command. For more information on available commands, see Using Galera Load Balancer.


When you run Galera Load Balancer, you can configure its use through the command-line options, which you can reference through the --help command. For users that run Galera Load Balancer as a service, you can manage it through the glbd.cfg configuration file.

  • LISTEN_ADDR Defines the address that Galera Load Balancer monitors for incoming client connections.
  • DEFAULT_TARGETS Defines the default servers that Galera Load Balancer routes incoming client connections to. For this parameter, use the IP addresses for the nodes in your cluster.
  • OTHER_OPTIONS Defines additional Galera Load Balancer options, such as the balancing policy you want to use. Use the same format as they would appear on the command-line.

For instance,

# Galera Load Balancer COnfigurations
OTHER_OPTIONS="--random --top 3"

Destination Selection Policies

Galera Load Balancer, both the system daemon and the shared library, support five destination selection policies. When you run it from the command-line, you can define these using the command-line arguments, otherwise add the arguments to the OTHER_OPTIONS parameter in the glbd.cfg configuration file.

  • Least Connected Directs new connections to the server using the smallest number of connections possible, which is adjusted for the server weight. This is the default policy.
  • Round Robin Directs new connections to the next destination in the circular order list. You can enable it through the –round option.
  • Single Directs all connections to the single server with the highest weight of those available. Routing continues to that server until it fails or a server with a higher weight becomes available. You can enable it through the –single option.
  • Random Directs connections randomly to available servers. You can enable it through the –random option
  • Source Tracking Directs connections originating from the same address to the same server. You can enable it through the –source option.

Using Galera Load Balancer

In the above section Service Installation, you configured your system to run Galera Load Balancer as a service. This allows you to manage common operations through the service command, for instance:

# service glb getinfo

     Address       : weight   usage  cons : 1.000    0.000    0 : 1.000    0.000    0 : 1.000    0.000    0
Destinations: 3, total connections: 0

The service script supports the following operations:

  • start/stop/restart Commands to start, stop and restart Galera Load Balancer.
  • getinfo Command provides the current routing information: the servers available, their weight and usage, the number of connections made to them.
  • add/remove <IP Address> Add or remove the designated IP address from the routing table.
  • getstats Command provides performance statistics.
  • drain <IP Address> Sets the designated server to drain. That is, Galera Load Balancer does not allocate new connections to the server, but also does not kill existing connections. Instead, it waits for the connections to this server to end gracefully.

When adding an IP address to Galera Load Balancer at runtime, bear in mind that it must follow the convention: IP Address:port:weight. When adding through a hostname, the convention is Hostname:port:weight.