Better solution for the Tornado 5 + SockJS + haproxy issue

Looks like Nagle's algorithm was the cause. Adding

    option http-no-delay

to haproxy.cfg solves the problem without modification of the timeout,
however that is not an option for the thousands of instances already
deployed in the field.

So instead we add 300ms to the roundtrip based connection timeout, that
should hopefully get around any Nagle-induced delays (usually between
40 and 200ms according to various sites on the net).
This commit is contained in:
Gina Häußge committed 2018-04-12 13:19:02 +02:00
1 parent 132614045c
commit 9c923be5f0
1 file changed
+2 -2
+2 -2
View File
@@ -817,8 +817,8 @@ SockJS.prototype._connect = function() {
}
}
// calculate timeout based on RTO and round trips. Default to 5s
var timeoutMs = (this._rto * Transport.roundTrips * 2) || 5000;
// calculate timeout based on RTO and round trips, compensate for potential nagle. Default to 5s.
var timeoutMs = (this._rto * Transport.roundTrips + 300) || 5000;
this._transportTimeoutId = setTimeout(this._transportTimeout.bind(this), timeoutMs);
debug('using timeout', timeoutMs);