]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 3552 pt3: Happy Eyeballs: Parallel TCP connection attempts (#386)
authorChristos Tsantilas <christos@chtsanti.net>
Thu, 15 Aug 2019 08:21:08 +0000 (08:21 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 15 Aug 2019 08:21:15 +0000 (08:21 +0000)
commit5562295321debdf33b59f772bce846bf6dd33c26
tree226e5787257ed7fab588728e5c16a53ec8fcf21f
parente287364cf8403222ec87111f5243b45ea9d2499e
Bug 3552 pt3: Happy Eyeballs: Parallel TCP connection attempts (#386)

A site with both AAAA and A DNS records may only be available via one of
the IP address families; attempts to connect to that site over the other
IP family will fail, sometimes after painful timeouts. Prior to these
changes, Squid tried to connect to resolved addresses sequentially,
which often resulted in unhappy user eyeballs and aborted (by clients)
client-Squid connections, especially when the first DNS answer contained
multiple unusable IP addresses.

To reduce user-visible delays, Squid now follows the Happy Eyeballs (RFC
8305) strategy: Start opening a to-server TCP connection using IPvX and,
if that "primary" connection was not established fast enough, initiate a
parallel "spare" connection opening attempt using IPvY. As before, X is
the IP protocol family in the first/fastest DNS response received by
Squid. As more IP addresses (from each family) become known, they feed
subsequent connection opening attempts on primary and spare tracks.

No changes in peer selection. No changes in peer usage: Squid still
exhausts all paths to peer[N] before using peer[N+1] IPs, even if it
means waiting for DNS A answer for peer[N] while sitting on an AAAA
answer for peer[N+1].

Happy Eyeballs implementations must balance the desire to improve
response times (by opening as many parallel connections as fast as
possible) with the dangers of triggering DoS alarms and creating
significant traffic overheads. To control that balance, Squid never uses
more than two parallel tracks for forwarding a single request and
provides three admin-configurable parameters (with reasonable defaults).

* happy_eyeballs_connect_timeout forces spare connection establishment
  track to wait a little (to give the primary track a chance to
  establish a connection).

* happy_eyeballs_connect_gap spaces out spare connection openings (to
  minimize spare traffic).

* happy_eyeballs_connect_limit caps the total number of spare
  connections (to reduce stress on Squid resources).

This is a Measurement Factory project.
18 files changed:
src/FwdState.cc
src/FwdState.h
src/HappyConnOpener.cc [new file with mode: 0644]
src/HappyConnOpener.h [new file with mode: 0644]
src/Makefile.am
src/PeerSelectState.h
src/ResolvedPeers.cc [new file with mode: 0644]
src/ResolvedPeers.h [new file with mode: 0644]
src/SquidConfig.h
src/base/AsyncJobCalls.h
src/base/Makefile.am
src/base/forward.h [new file with mode: 0644]
src/cf.data.pre
src/dns_internal.cc
src/http.cc
src/pconn.cc
src/pconn.h
src/tunnel.cc