Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/container/docker/squid.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,16 @@ func writeIngressProxyConfig(
) {
portNum := strconv.Itoa(upstreamPort)
squidPortNum := strconv.Itoa(squidPort)
// standby=2 keeps warm idle connections open to the upstream so the first
// request after a cold start (notably a long-lived GET SSE stream that a
// server-initiated request rides on) is forwarded without paying inline DNS
// + TCP connect latency. Without it, the cold first GET races behind a
// later POST that reuses a warmed path, reordering server->client streams.
sb.WriteString(
"\n# Reverse proxy setup for port " + portNum + "\n" +
"http_port 0.0.0.0:" + squidPortNum + " accel defaultsite=" + serverHostname + "\n" +
"cache_peer " + serverHostname + " parent " + portNum + " 0 no-query originserver name=origin_" +
portNum + " connect-timeout=5 connect-fail-limit=5\n")
portNum + " connect-timeout=5 connect-fail-limit=5 standby=2\n")

// Check if inbound network permissions are configured
if networkPermissions != nil && networkPermissions.Inbound != nil && len(networkPermissions.Inbound.AllowHost) > 0 {
Expand Down
3 changes: 3 additions & 0 deletions pkg/container/docker/squid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ func TestCreateTempIngressSquidConf_Basics(t *testing.T) {
assert.Contains(t, s, "\n# Reverse proxy setup for port 8080\n")
assert.Contains(t, s, "http_port 0.0.0.0:18080 accel defaultsite=svc-example")
assert.Contains(t, s, "cache_peer svc-example parent 8080 0 no-query originserver name=origin_8080")
// standby=2 pre-warms upstream connections so a cold first GET SSE stream is
// not reordered behind a later POST (fixes the sampling conformance flake).
assert.Contains(t, s, "connect-timeout=5 connect-fail-limit=5 standby=2")
assert.Contains(t, s, "acl site_8080 dstdomain svc-example")
assert.Contains(t, s, "http_access allow site_8080")
assert.True(t, strings.HasSuffix(strings.TrimSpace(s), "http_access deny all"))
Expand Down
Loading