Setting up Galera Load Balancer (GLB)

Galera Load Balancer (GLB) is a scalable and performant, yet easy to use TCP/IP connection balancing proxy. It is the oldest, yet actively maintained load balancer in the MySQL ecosystem, with a wide array of customers using it in production.

Firstly, please request for binaries via contacting sales@galeracluster.com. Once you have access to the package repository, you’ll have access to RPMs. Installing the RPMs are straightforward, and you can also add it to your Yum repository. This blog presumes you already have access to the binaries.

You can start it up, really simply:

glbd --threads 6 127.0.0.1:3306 188.166.179.177:3306 165.22.50.152:3306 165.22.49.92:3306

This is telling glbd to run with 6 threads, and to listen on localhost for port 3306. You might want to do this on the open Internet, so we would suggest replacing 127.0.0.1 with the IP address of the host of your choice. So in a test production instance, we start it like:

glbd --threads 6 134.209.96.103:3306 188.166.179.177:3306 165.0.152:3306 165.22.49.92:3306

When it starts, you will see:

[root@glb ~]# glbd --threads 6 134.209.96.103:3306 188.166.179.177:3306 165.22.50.152:3306 165.22.49.92:3306
glb v1.0.1 (epoll)
Incoming address: 134.209.96.103:3306, control FIFO: /tmp/glbd.fifo
Control  address:  none
Number of threads: 6, max conn: 493, nodelay: ON, keepalive: ON, defer accept: OFF, linger: OFF, daemon: NO, lat.count: 0, policy: 'least connected', top: NO, verbose: NO
Destinations: 3
   0: 188.166.179.177:3306 , w: 1.000
   1:   165.22.50.152:3306 , w: 1.000
   2:    165.22.49.92:3306 , w: 1.000
Router:
------------------------------------------------------
        Address       :   weight   usage    map  conns
188.166.179.177:3306  :    1.000   0.000    N/A      0
  165.22.50.152:3306  :    1.000   0.000    N/A      0
   165.22.49.92:3306  :    1.000   0.000    N/A      0
------------------------------------------------------
Destinations: 3, total connections: 0 of 493 max

Pool: connections per thread:     0     0     0     0     0     0

You will notice that the incoming address in this case is the server address. We chose to use port 3306, but you can also use something else, e.g. 4444. Just remember that when you use mysql to connect, you need to specify the port.

We just set it to 6 threads, and the default maximum connections are 493 (also, configurable). Everything has a weight of 1.

When a connection is successfully made, you’ll see that there is some usage:

Router:
------------------------------------------------------
        Address       :   weight   usage    map  conns
188.166.179.177:3306  :    1.000   0.500    N/A      1
  165.22.50.152:3306  :    1.000   0.000    N/A      0
   165.22.49.92:3306  :    1.000   0.000    N/A      0
------------------------------------------------------
Destinations: 3, total connections: 1 of 493 max

And by the time we are ready to make 3 connections, the usage is evenly distributed:

Router:
------------------------------------------------------
        Address       :   weight   usage    map  conns
188.166.179.177:3306  :    1.000   0.500    N/A      1
  165.22.50.152:3306  :    1.000   0.500    N/A      1
   165.22.49.92:3306  :    1.000   0.500    N/A      1
------------------------------------------------------
Destinations: 3, total connections: 3 of 493 max

And by the fourth:

Router:
------------------------------------------------------
        Address       :   weight   usage    map  conns
188.166.179.177:3306  :    1.000   0.667    N/A      2
  165.22.50.152:3306  :    1.000   0.500    N/A      1
   165.22.49.92:3306  :    1.000   0.500    N/A      1
------------------------------------------------------
Destinations: 3, total connections: 4 of 493 max

Pool: connections per thread:     1     1     1     1     0     0

This is how Galera Load Balancer (GLB) is started manually on the command line, with complete query information. Do you want to know more about how to configure Galera Load Balancer (GLB)? Just type glbd with no options and you’ll see a complete list of help (or you can do this via glbd -h). In followups, we will show you how to run this as a daemon, and how to further configure your Galera Load Balancer (GLB).