fix: correct too-aggressive HAProxy keep-alive timeout from #39 #40

Open
emily wants to merge 1 commits from emily/nixos:fix/haproxy-keepalive-timeout-too-aggressive into main
+19 -4
View File
@@ -178,10 +178,24 @@ in
timeout server 1h timeout server 1h
# HAProxy defaults to end-to-end keep-alive (client AND server side) # HAProxy defaults to end-to-end keep-alive (client AND server side)
# unless a proxy overrides it. Bound how long an idle client-facing # unless a proxy overrides it. Bound how long an idle client-facing
# keep-alive connection is held: maxconn is only 80, and leaving # keep-alive connection is held rather than falling back to
# this unset falls back to "timeout client" (500s), which is far # "timeout client" (500s).
# longer than needed just to wait for a pipelined next request. #
timeout http-keep-alive 30s # CORRECTION (see #39): this was originally set to 30s as a
# tidy-up given maxconn=80, without considering client-side
# connection pooling behavior. That was too aggressive: DAVx5 (and
# OkHttp-based HTTP clients generally) keep idle pooled
# connections open for up to 5 minutes client-side before
# eviction. With a 30s haproxy-side timeout, any client connection
# idle between 30s-300s got silently closed by haproxy, and the
# client's next reuse of it produced exactly the "unexpected end
# of stream"/EOFException class of error this investigation
# started from - just relocated from the haproxy<->nginx leg
# (fixed in `backend next` below) to the client<->haproxy leg.
# Set comfortably above OkHttp's 300s default so a client's own
# pool eviction always happens first and haproxy is never the one
# to close a connection the client still thinks is good.
timeout http-keep-alive 6m
listen gitsshd listen gitsshd
bind *:${toString sshPort} bind *:${toString sshPort}
@@ -266,6 +280,7 @@ in
backend next backend next
log global log global
log-tag next
mode http mode http
balance roundrobin balance roundrobin
option accept-unsafe-violations-in-http-response option accept-unsafe-violations-in-http-response