UDP load balancing
UDP load balancing reference
Configuring udp-lb sections
udp-lb sections don’t inherit settings from defaults sections. You must define the following directives explicitly within each appropriate udp-lb section.
The UDP module uses the following directives for configuration.
accepted-payload-size Jump to heading
Sets the maximum UDP datagram payload size in bytes. The default value is 1472, and the maximum value allowed is 65507.
Syntaxtextaccepted-payload-size <number>
Syntaxtextaccepted-payload-size <number>
acl Jump to heading
This section applies to:
- HAProxy Enterprise 3.2r1 and newer
- Not available in HAProxy ALOHA
Configure an ACL (Access Control List). See ACLs for more implementation details.
Syntaxtextacl <name> <criterion> [<ACL flags>] [<operator>] <value>
Syntaxtextacl <name> <criterion> [<ACL flags>] [<operator>] <value>
balance Jump to heading
Sets the load balancing algorithm.
Syntaxtextbalance <algorithm>
Syntaxtextbalance <algorithm>
The UDP module supports the following algorithms for balance:
static-rrroundrobinleastconnfirstsourcerandom
default-server Jump to heading
Sets default parameters that will apply to all server lines within the same section. For a list of supported parameters, see default-server options.
Syntaxtextdefault-server [param*]
Syntaxtextdefault-server [param*]
dgram-bind Jump to heading
Configures a datagram listener to receive messages to forward. Addresses must be in IPv4 or IPv6 form, optionally followed by a port.
Syntaxtextdgram-bind <addr> [param*]
Syntaxtextdgram-bind <addr> [param*]
The dgram-bind directive supports these bind parameters:
maxconnnamespaceniceshardsthreadtransparent
hash-balance-factor Jump to heading
This section applies to:
- HAProxy ALOHA 17.0 and newer
- HAProxy Enterprise 3.1r1 and newer
Specifies the balancing factor for bounded-load consistent hashing. See hash-balance-factor for more details.
Syntaxtexthash-balance-factor <factor>
Syntaxtexthash-balance-factor <factor>
hash-type Jump to heading
This section applies to:
- HAProxy ALOHA 17.0 and newer
- HAProxy Enterprise 3.1r1 and newer
Specifies a method to use for mapping hashes to servers. See hash-type for more details.
Syntaxtexthash-type <method> <function> <modifier>
Syntaxtexthash-type <method> <function> <modifier>
log Jump to heading
This section applies to:
- HAProxy ALOHA 17.0 and newer
- HAProxy Enterprise 3.0r1 and newer
Enables per-instance logging of events. For requests, the source is the client’s IP/port, and the destination is the listener’s IP/port. For responses, the source is the listener, and the destination is the client.
For details, see log reference.
Syntaxtextlog <target> [len <length>] [format <format>] [sample <ranges>:<sample_size>] <facility> [<level> [<minlevel>]]
Syntaxtextlog <target> [len <length>] [format <format>] [sample <ranges>:<sample_size>] <facility> [<level> [<minlevel>]]
log global Jump to heading
This section applies to:
- HAProxy ALOHA 17.0 and newer
- HAProxy Enterprise 3.0r1 and newer
Sets the instance’s logging parameters to be the same as the global ones.
Syntaxtextlog global
Syntaxtextlog global
log-tag Jump to heading
This section applies to:
- HAProxy ALOHA 17.0 and newer
- HAProxy Enterprise 3.0r1 and newer
Sets the log tag string to use for all outgoing logs.
Syntaxtextlog-tag <string>
Syntaxtextlog-tag <string>
maxconn Jump to heading
Sets the maximum number of concurrent connections. Once the limit is reached, all datagrams received initiating new UDP connection will be dropped.
Syntaxtextmaxconn <integer>
Syntaxtextmaxconn <integer>
option persist Jump to heading
This section applies to:
- HAProxy Enterprise 3.2r1 and newer
- Not available in HAProxy ALOHA
Enables forced persistence on downed servers by forcing the datagram to be sent to the downed server(s) first.
Syntaxtextoption persist
Syntaxtextoption persist
option tcp-check Jump to heading
Performs health checks using TCP connection attempts.
Syntaxtextoption tcp-check
Syntaxtextoption tcp-check
option udp-check Jump to heading
Performs health checks via ICMP.
Syntaxtextoption udp-check
Syntaxtextoption udp-check
proxy-requests Jump to heading
Sets the number of expected datagrams per client session. Since UDP isn’t a connection-oriented protocol, the UDP module must keep track of a client’s session such that it can route the response datagrams from an upstream server back to the correct client. Each session is indexed by the 4-tuple consisting of source IP/port and destination IP/port corresponding to the datagram.
-
If this option isn’t set, then the load balancer will forward all datagrams from the client to the same backend server as long as the client is considered alive. If the client becomes inactive, their session expires, and the next time they send a datagram, the load balancer will again choose a server based on the load balancing algorithm.
-
If this option is set to a value greater than 0, then session stickiness is disabled and the load balancer will choose the backend server on every
<number>datagrams received. For example, if set toproxy-requests 1, then a destination server will be rotated after each datagram received from the client.
Syntaxtextproxy-requests <number>
Syntaxtextproxy-requests <number>
proxy-responses Jump to heading
Sets the number of expected responses from the server. Sessions last until the timeout is reached or the expected number of responses has been received. If a zero value is specified, all responses from the server will be ignored and not forwarded back to the client. If a value isn’t specified, the number of expected responses is set to unlimited.
Syntaxtextproxy-responses <number>
Syntaxtextproxy-responses <number>
server Jump to heading
Configures a target server.
Syntaxtextserver <name> <address>[:[port]] [param*]
Syntaxtextserver <name> <address>[:[port]] [param*]
source Jump to heading
Sets the source address for outgoing connections. The <addr> and optional <port> will be used for binding before connecting to the server. The <addr2> and <port2> are presented to the server when connections are forwarded in full transparent proxy mode. If client or clientip is set, the load balancer will present the client’s IP address and port, or the client’s IP address only.
Syntax for setting source addresstextsource <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Syntax for setting source addresstextsource <addr>[:<port>] [usesrc { <addr2>[:<port2>] | client | clientip } ]
Syntax for setting interface nametextsource <addr>[:<port>] [interface <name>]
Syntax for setting interface nametextsource <addr>[:<port>] [interface <name>]
tcp-check Jump to heading
Configures TCP health checking.
Syntaxtexttcp-check <option> [param*]
Syntaxtexttcp-check <option> [param*]
Supported options are:
commentconnectsendsend-lfsend-binarysend-binary-lfexpectset-varset-var-fmtunset-var
timeout client Jump to heading
Sets the maximum inactivity time on the client side. The default is 10 seconds, but the ideal setting depends on your traffic and application. For example, if you have a large amount of traffic and a large number of client IP addresses and ports, you can lower the value in order to avoid tracking a high number of connections unnecessarily.
Syntaxtexttimeout client <timeout>
Syntaxtexttimeout client <timeout>
timeout server Jump to heading
Sets the maximum inactivity time on the server side.
Syntaxtexttimeout server <timeout>
Syntaxtexttimeout server <timeout>
use-server Jump to heading
This section applies to:
- HAProxy Enterprise 3.2r1 and newer
- Not available in HAProxy ALOHA
Assign a specified server if/unless a condition is matched. For example, use a target UDP server based on the source IP.
If there is more than one use-server directive configured, they are evaluated in their declaration order. The first use-server directive that matches a condition will assign the specified server, unless the current session has already assigned that server. If no condition is valid, the unassigned servers will use other load balancing mechanisms.
When <server> is a simple name, the load balancer is checks it against existing servers in the configuration and reports an error if the specified server doesn’t exist. If <server> is in a custom log format, no check is performed when parsing the configuration. If the load balancer can’t resolve a valid server name at runtime, but a use-server was condition was met, no other use-server directive is applied, and the load balancer will fall back to load balancing.
Syntaxtextuse-server <server> { if | unless } <condition>
Syntaxtextuse-server <server> { if | unless } <condition>
Do you have any suggestions on how we can improve the content of this page?