Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does HAProxy recommend setting timeouts that are multiples of 3 seconds?

Tags:

tcp

haproxy

From the HAProxy documentation on client timeouts:

It is a good practice to cover one or several TCP packet losses by specifying timeouts that are slightly above multiples of 3 seconds (eg: 4 or 5 seconds).

That seems like an arbitrary number. What is the significance of the 3 second figure?

like image 830
Kevin Burke Avatar asked Dec 07 '25 00:12

Kevin Burke


1 Answers

It appears this is the default TCP retransmission timeout. From this Microsoft KB article:

TCP starts a re-transmission timer when each outbound segment is handed down to IP. If no acknowledgment has been received for the data in a given segment before the timer expires, then the segment is retransmitted, up to the TcpMaxDataRetransmissions times. The default value for this parameter is 5.

The re-transmission timer is initialized to 3 seconds when a TCP connection is established; however it is adjusted "on the fly" to match the characteristics of the connection using Smoothed Round Trip Time (SRTT) calculations as described in RFC793. The timer for a given segment is doubled after each re-transmission of that segment. Using this algorithm, TCP tunes itself to the "normal" delay of a connection. TCP connections over high-delay links will take much longer to time out than those over low- delay links.

like image 194
Kevin Burke Avatar answered Dec 08 '25 22:12

Kevin Burke