HAProxy ALOHA Documentation 13.5

LB Layer4 reference

Use the LB Layer4 tab to specify director definitions for the Linux Virtual Server (LVS) service.

The layer 4 load balancer is the IPVS component of the Linux Virtual Server (LVS) project. For details, see:

Configuration file syntax

The file consists of a list of director sections.

director <name> [ <ip>[:<port>] [TCP|UDP] ]
   balance { roundrobin | leastconn [localitybased [replication]] | source |
             srcdst | dest | shortestexpected | neverqueue }
   mode { gateway | nat | tunnel }
   check { [timeout <seconds>] [interval <seconds>] [source <ip>] [port <port>] }
   option { persistence [timeout <seconds>] [netmask <netmask>] |
             httpcheck [uri <uri>] [statuscode <int>] [vhost <string>] |
             tcpcheck | arpcheck [iface <name>] | icmpcheck }

   server <name> <ip>[:<port>] [weight <int>] [check] [sorry]
   [server]...

Term

Description

director

Specifies a unique identifier for the director, the IP and port for incoming traffic, and the protocol.

balance

Load balancing algorithm, one of:

Algorithm

Description

roundrobin

Distributes jobs equally among the available servers. Jobs are assigned to servers in proportion their weight. Servers with higher weights receive new jobs first and get more jobs than servers with lower weights. Servers with equal weights get an equal distribution of new jobs.

leastconn

Assigns more jobs to servers with fewer jobs and relative to the real servers' weight (Ci/Wi). This is the default.

leastconn localitybased

Assigns jobs destined for the same IP address to the same server if the server is available and not overloaded. Otherwise, assign jobs to servers with fewer jobs, and keep it for future assignment.

leastconn localitybased replication

Assigns jobs destined for the same IP address to the least-connection node in the server set for the IP address. If all nodes in the server set are overloaded, it picks up a node with fewer jobs in the cluster and adds it in the sever set for the target. If the server set has not been modified for the specified time, the most heavily loaded node is removed from the server set, in order to avoid excessive replication.

dest

Assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses.

source

Assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses.

srcdst

Assigns jobs to servers through looking up a statically assigned hash table by their source and destination IP addresses.

shortexpdelay

Assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the the ith server and Ui is the fixed service rate (weight) of the ith server.

neverqueue

Assigns an incoming job to an idle server if one exists, instead of waiting for a fast one. If all servers are busy, it adopts the Shortest Expected Delay policy to assign the job.

mode

One of:

Mode

Description

gateway

Use direct routing.

nat

Use destination masquerading (network access translation, or NAT).

tunnel

Use ipip encapsulation (tunneling).

check

Specify global check parameters. If no advanced check mode is defined using these options, icmp checks are performed. Any of:

Option

Description

timeout <seconds>

Duration in seconds. If no connection established, check failed. The default is half of check interval.

interval <seconds>

Interval between checks in seconds. The default is 10 seconds.

source <ip>

Force source IP to use.

port <port>

Force port destination. (Only on tcpcheck and httpcheck. By default and if it exists, the real-server port is used).

rise <count>

A server will be considered as operational after <count> consecutive successful health checks. The default is 1.

fall <count>

A server will be considered as dead after <count> consecutive unsuccessful health checks. The default is 1.

inhibit

If a server is down, its weight is passed to 0 but not deleted. Established connection are not broken but new connections are dispatched on the other servers.

option persistence

Specify that a virtual service is persistent. If this option is specified, multiple requests from a client are redirected to the same real server selected for the first request. This option may be used in conjunction with protocols such as SSL or FTP where it is important that clients consistently connect with the same real server. Any of:

Option

Description

timeout <seconds>

The timeout of persistent sessions may be specified, given in seconds.

netmask <netmask>

Specify the granularity with which clients are grouped for persistent virtual services, as a net mask. The source address of the request is masked with this netmask to direct all clients from a network to the same real server. The default is 255.255.255.255, that is, the persistence granularity is per client host. Less specific netmasks may be used to resolve problems with non-persistent cache clusters on the client side.

option httpcheck

Testing method. Checks performing an HTTP GET request on real server IP. Any of:

Option

Description

uri <uri>

Requested uri. (default is root / ).

statuscode <int>

Expected status code. (default is 200).

vhost <string>

String to set in Host header field.

option tcpcheck

Testing method. Checks opening a TCP connection on real server IP.

option arpcheck

Testing method. Checks sending an arp-whoas to real server IP. Any of:

Option

Description

iface <name>

Network interface name.

option icmpcheck

Testing method. Checks sending an icmp echo request to real server ip.

option onepacket

One-packet scheduling. This option can be used only for UDP. Option is useful for scheduling UDP packets from same client port to different real servers.

server

Specify parameters for backend servers.

Parameter

Description

name

Unique identifier for the server.

IP[:port]

IP address and optional port of server. If port is omitted, it defaults to destination port specified in incoming packet.

weight <int>

Optional. Numeric weight of the server.

check

Optional. Activate checks on the server. Check options are same as for director, above.

sorry

Optional. Classify this server as a "sorry" server. It is used if all other servers are unavailable.

LVS manager invocation options

Invocation options for the lvs service are configured on the Services tab.


Next up

LB Layer7 reference