how do I tune keepalive probes
how do I tune keepalive probes
Tuning keepalive probes in HAProxy involves setting various parameters on both the client and server sides to manage the TCP keepalive behavior. Here’s how you can configure these settings:
You can enable TCP keepalive probes with the following options:
Client Side Keepalive: Use option clitcpka
to enable the emission of TCP keepalive probes from HAProxy to the clients. More details on this can be found in the Proxies - Alphabetically sorted keywords reference.
Server Side Keepalive: Use option srvtcpka
to enable the emission of TCP keepalive probes from HAProxy to the backend servers. More information is available in the Proxies - Alphabetically sorted keywords reference.
After enabling TCP keepalive, you can set specific parameters to control its behavior:
Client Side Configuration:
clitcpka-idle <timeout>
: Time in seconds that the connection must be idle before starting to send keepalive probes. Details here.clitcpka-intvl <timeout>
: Time in seconds between individual keepalive probes. More information.clitcpka-cnt <count>
: Maximum number of keepalive probes to send before considering the connection dead. Documentation link.Server Side Configuration:
srvtcpka-idle <timeout>
: Time in seconds that the connection must be idle before HAProxy begins sending keepalive probes to the server. Reference here.srvtcpka-intvl <timeout>
: Interval in seconds between keepalive probes. Documentation link.srvtcpka-cnt <count>
: Maximum number of keepalive probes HAProxy sends before dropping the connection. Details here.Here’s an example of how you might configure these options in a HAProxy configuration file:
defaults
option clitcpka
option srvtcpka
frontend main
bind *:80
default_backend servers
backend servers
server server1 192.168.0.1:80 check
clitcpka-idle 30
clitcpka-intvl 10
clitcpka-cnt 5
srvtcpka-idle 30
srvtcpka-intvl 10
srvtcpka-cnt 5
In this configuration, both client and server side TCP keepalives are enabled with specific idle times, intervals, and probe counts, helping to maintain persistent connections effectively.
Adjust these values according to your network characteristics and traffic patterns to optimize the keepalive behavior and resource utilization in your HAProxy setup.