Galera Load Balancer Parameters

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.

It can be run either through the service command or the command-line interface of glbd. Configuration for Galera Load Balancer depends on which you use to run it.

Configuration Parameters

When Galera Load Balancer starts as a system service, it reads the glbd.cfg configuration file for default parameters you want to use. Only the LISTEN_ADDR parameter is mandatory.

Parameter Default Configuration
CONTROL_ADDR 127.0.0.1:8011
CONTROL_FIFO /var/run/glbd.fifo
DEFAULT_TARGETS 127.0.0.1:80 10.0.1:80 10.0.0.2:80
LISTEN_ADDR 8010
MAX_CONN  
OTHER_OPTIONS  
THREADS 2

CONTROL_ADDR

Defines the IP address and port for controlling connections.

Command-line Argument –control
Default Configuration 127.0.0.1:8011
Mandatory Parameter No

This is an optional parameter. Use it to define the server used in controlling client connections. When using this parameter you must define the port. In the event that you do not define this parameter, Galera Load Balancer does not open the relevant socket.

CONTROL_ADDR="127.0.0.1:8011"

CONTROL_FIFO

Defines the path to the FIFO control file.

Command-line Argument –fifo
Default Configuration /var/run/glbd.fifo
Mandatory Parameter No

This is an optional parameter. It defines the path to the FIFO control file as is always opened. In the event that there is already a file at this path, Galera Load Balancer fails to start.

CONTROL_FIFO="/var/run/glbd.fifo"

DEFAULT_TARGETS

Defines the IP addresses and ports of the destination servers.

Default Configuration 127.0.0.1:80 10.0.0.1:80 10.0.0.2:80:2
Mandatory Parameter No

This parameter defines that IP addresses that Galera Load Balancer uses as destination servers. Specifically, in this case the Galera Cluster nodes that it routes application traffic onto.

DEFAULT_TARGETS="192.168.1.1 192.168.1.2 192.168.1.3"

LISTEN_ADDR

Defines the IP address and port used for client connections.

Default Configuration 8010
Mandatory Parameter Yes

This parameter defines the IP address and port that Galera Load Balancer listens on for incoming client connections. The IP address is optional, the port mandatory. In the event that you define a port without an IP address, Galera Load Balancer listens on that port for all available network interfaces.

LISTEN_ADDR="8010"

MAX_CONN

Defines the maximum allowed client connections.

Command-line Argument –max_conn
Mandatory Parameter No

This parameter defines the maximum number of client connections that you want to allow to Galera Load Balancer. It modifies the system open files limit to accommodate at least this many connections, provided sufficient privileges. It is recommend that you define this parameter if you expect the number of client connections to exceed five hundred.

MAX_CONN="135"

This option defines the maximum number of client connections that you want allow to Galera Load Balancer. Bear in mind, that it can be operating system dependent.

OTHER_OPTIONS

Defines additional options that you want to pass to Galera Load Balancer.

Mandatory Parameter No

This parameter defines various additional options that you would like to pass to Galera Load Balancer, such as a destination selection policy or Watchdog configurations. Use the same syntax as you would for the command-line arguments. For more information on the available options, see Configuration Options.

OTHER_OPTIONS="--random --watchdog exec:'mysql -utest -ptestpass' --discover"

THREADS

Defines the number of threads you want to use.

Command-line Argument –threads
Mandatory Parameter No

This parameter allows you to define the number of threads (that is, connection pools), which you want to allow Galera Load Balancer to use. It is advisable that you have at least a few per CPU core.

THREADS="6"

Configuration Options

When Galera Load Balancer starts as a daemon process, through the /sbin/glbd command, it allows you to pass a number of command-line arguments to configure how it operates. It uses the following syntax:

/usr/local/sbin/glbd [OPTIONS] LISTEN_ADDRESS [DESTINATION_LIST]

In the event that you would like to set any of these options when you run Galera Load Balancer as a service, you can define them through the OTHER_OPTIONS parameter.

Long Argument Short Type Parameter
–control -c IP address CONTROL_ADDR
–daemon -d Boolean  
–defer-accept -a Boolean  
–discover -D Boolean  
–extra -x Decimal  
–fifo -f File Path CONTROL_FIFO
–interval -i Decimal  
–keepalive -K Boolean  
–latency -L Integer  
–linger -l Boolean  
–max_conn -m Integer MAX_CONN
–nodelay -n Boolean  
–random -r Boolean  
–round -b Boolean  
–single -S Boolean  
–source -s Boolean  
–threads -t Integer THREADS
–top -T Boolean  
–verbose -v Boolean  
–watchdog -w String  

--control

Defines the IP address and port for control connections.

Short Argument -c
Syntax --control [IP|Hostname:]port
Type IP Address
Configuration Parameter CONTROL_ADDR

For more information on defining the controlling connections, see the CONTROL_ADDR parameter.

# glbd --control 192.168.1.1:80 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--daemon

Defines whether you want Galera Load Balancer to run as a daemon process.

Short Argument -d
Syntax --daemon
Type Boolean

This option defines whether you want to start glbd as a daemon process. That is, if you want it to run in the background, instead of claiming the current terminal session.

# glbd --daemon 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--defer-accept

Enables TCP deferred acceptance on the listening socket.

Short Argument -a
Syntax --defer-accept
Type Boolean

Enabling TCP_DEFER_ACCEPT allows Galera Load Balancer to awaken only when data arrives on the listening socket. It is disabled by default.

# glbd --defer-accept 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--discover

Defines whether you want to use watchdog results to discover and set new destinations.

Short Argument -D
Syntax --discover
Type Boolean

When you define the –watchdog option, this option defines whether Galera Load Balancer uses the return value in discovering and setting new addresses for destination servers. For instance, after querying for the wsrep_cluster_address parameter.

# glbd --discover -w exec:"mysql.sh -utest -ptestpass" 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--extra

Defines whether you want to perform an extra destination poll on connection attempts.

Short Argument -x
Syntax --extra D.DDD
Type Decimal

This option defines whether and when you want Galera Load Balancer to perform an additional destination poll on connection attempts. The given value indicates how many seconds after the previous poll that you want it to run the extra poll. By default, the extra polling feature is disabled.

# glbd --extra 1.35 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--fifo

Defines the path to the FIFO control file.

Short Argument -f
Syntax --fifo /path/to/glbd.fifo
Type File Path
Configuration Parameter CONTROL_FIFO

For more information on using FIFO control files, see the CONTROL_FIFO parameter.

# glbd --fifo /var/run/glbd.fifo 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--interval

Defines how often to probe destinations for liveliness.

Short Argument -i
Syntax --interval D.DDD
Type Decimal

This option defines how often Galera Load Balancer checks destination servers for liveliness. It uses values given in seconds. By default, it checks every second.

# glbd --interval 2.013 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--keepalive

Defines whether you want to disable the SO_KEEPALIVE socket option on server-side sockets.

Short Argument -K
Syntax --keepalive
Type Boolean

Linux systems feature the socket option SO_KEEPALIVE, which causes the server to send packets to a remote system in order to main the client connection with the destination server. This option allows you to disable SO_KEEPALIVE on server-side sockets. It allows SO_KEEPALIVE by default.

# glbd --keepalive 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--latency

Defines the number of samples to take in calculating latency for watchdog.

Short Argument -L
Syntax --latency N
Type Integer

When the Watchdog module tests a destination server to calculate latency, it sends a number of packets through to measure its responsiveness. This option configures how many packets it sends in sampling latency.

# glbd --latency 25 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--linger

Defines whether Galera Load Balancer disables sockets lingering after they are closed.

Short Argument -l
Syntax --linger
Type Boolean

When Galera Load Balancer sends the close() command, occasionally sockets linger in a TIME_WAIT state. This options defines whether or not you want Galera Load Balancer to disable lingering sockets.

# glbd --linger 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--max_conn

Defines the maximum allowed client connections.

Short Argument -m
Syntax --max_conn N
Type Integer

For more information on defining the maximum client connections, see the MAX_CONN parameter.

# glbd --max_conn 125 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--nodelay

Defines whether it disables the TCP no-delay socket option.

Short Argument -n
Syntax --nodelay
Type Boolean

Under normal operation, TCP connections automatically concatenate small packets into larger frames through the Nagle algorithm. In the event that you want Galera Load Balancer to disable this feature, this option causes it to open TCP connections with the TCP_NODELAY feature.

# glbd --nodelay 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--random

Defines the destination selection policy as Random.

Short Argument -r
Syntax --random
Type Boolean

The destination selection policy determines how Galera Load Balancer determines which servers to route traffic to. When you set the policy to Random, it randomly chooses a destination from the pool of available servers. You can enable this feature by default through the OTHER_OPTIONS parameter.

For more information on other policies, see Destination Selection Policies.

# glbd --random 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--round

Defines the destination selection policy as Round Robin.

Short Argument -b
Syntax --round
Type Boolean

The destination selection policy determines how Galera Load Balancer determines which servers to route traffic to. When you set the policy to Round Robin, it directs new connections to the next server in a circular order list. You can enable this feature by default through the OTHER_OPTIONS parameter.

For more information on other policies, see Destination Selection Policies.

# glbd --round 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--single

Defines the destination selection policy as Single.

Short Argument -S
Syntax --single
Type Boolean

The destination selection policy determines how Galera Load Balancer determines which servers to route traffic to.

When you set the policy to Single, all connections route to the server with the highest weight value. You can enable this by default through the OTHER_OPTIONS parameter.

# glbd --single 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--source

Defines the destination selection policy as Source Tracking.

Short Argument -s
Syntax --source
Type Boolean

The destination selection policy determines how Galera Load Balancer determines which servers to route traffic to. When you set the policy to Source Tracking, connections that originate from one address are routed to the same destination. That is, you can ensure that certain IP addresses always route to the same destination server. You can enable this by default through the OTHER_OPTIONS parameter.

Bear in mind, there are some limitations to this selection policy. When the destination list changes, the destination choice for new connections changes as well, while established connections remain in place. Additionally, when a destination is marked as unavailable, all connections that would route to it fail over to another, randomly chosen destination. When the original target becomes available again, routing to it for new connections resumes. In other words, Source Tracking works best with short-lived connections.

For more information on other policies, see Destination Selection Policies.

# glbd --source 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--threads

Defines the number of threads that you want to use.

Short Argument -t
Syntax --threads N
Type Integer

For more information on threading in Galera Load Balancer, see THREADS.

# glbd --threads 6 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--top

Enables balancing to top weights only.

Short Argument -T
Syntax --top
Type Boolean

This option restricts all balancing policies to a subset of destination servers with the top weight. For instance, if you have servers with weights 1, 2 and 3, balancing occurs only on servers with weight 3, while they remain available.

# glbd --top 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--verbose

Defines whether you want Galera Load Balancer to run as verbose.

Short Argument -v
Syntax --verbose
Type Boolean

This option enables verbose output for Galera Load Balancer, which you may find useful for debugging purposes.

# glbd --verbose 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

--watchdog

Defines specifications for watchdog operations.

Short Argument -w
Syntax --watchdog SPEC_STR
Type String

Under normal operation, Galera Load Balancer checks destination availability by attempting to establish a TCP connection to the server. For most use cases, this is insufficient. If you want to establish a connection with web server, you need to know if it is able to serve web pages. If you want to establish a connection with a database server, you need to know if it is able to execute queries. TCP connections don’t provide that kind of information.

The Watchdog module implements asynchronous monitoring of destination servers through back-ends designed to service availability. This option allows you to enable it by defining the back-end ID string, optionally followed by a colon and the configuration options.

# glbd -w exec:"mysql.sh -utest -ptestpass" 3306 \
      192.168.1.1 192.168.1.2 192.168.1.3

This initializes the exec back-end to execute external programs. It runs the mysql.sh script on each destination server in order to determine it’s availability. You can find the mysql.sh in the Galera Load Balancer build directory, under files/.

Note

The Watchdog module remains a work in progress. Neither its functionality nor terminology is final.