haproxy tcp keepalive

haproxy tcp keepalive

feat

  1. 使用内核协议栈的tcp keepalive特性,在tcp连接上,定时发送keepalive消息
  2. 当启用option http-keep-alive时,且正确配置了timeout client,option tcpka基本不会被触发
  3. tcp keepalive的相关参数,使用系统中的配置
    1. tcp_keepalive_time 连接空闲多久,才会发送keepalive消息,默认7200s;当连接上有数据时,该计时器会被重置
    2. tcp_keepalive_probes 每次开始发送keepalive消息时,多少个包没回复,就认为对端已经无响应,需要关闭连接了,默认9个包,即相当于9*75s, 约等于11分钟,才会断开连接
    3. tcp_keepalive_intvl 发送keepalive消息时的间隔,默认75s
  4. 通过clitcpka, srvtcpka, 或者tcpka来配置

配置项

  1. clitcpka 仅在客户端和listener的连接上,启用SO_KEEPALIVE
  2. srvtcpka 仅在haproxy和后端的连接上,启用SO_KEEPALIVE
  3. tcpka 配置在defaults/listen中时,客户端<->listener, haproxy<->后端,的连接都会启用SO_KEEPALIVE,配置在frontend 同clitcpka;配置在backend 同srvtcpka
posted @ 2021-01-07 16:05  哲淡  阅读(1217)  评论(0编辑  收藏  举报