Skip to content

Ingress Squid opens upstream connections lazily, skewing cold-start request timing #5886

Closed

Description

@jhrozek

Summary

ToolHive fronts non-stdio workloads with a Squid ingress reverse proxy (createIngressSquidContainer / writeIngressProxyConfig, pkg/container/docker/squid.go). The generated cache_peer line has no standby=N, so Squid opens its upstream (workload) connection lazily on first use. On a cold start, the first request through the ingress pays inline DNS + TCP connect latency to the workload, while later requests reuse a warmed connection.

For streamable-http workloads that send server-initiated requests on the client's standalone GET /mcp SSE stream — spec-allowed, and the MCP TypeScript SDK's default routing when a server→client request carries no relatedRequestId (e.g. sampling/createMessage, elicitation/create) — this asymmetric first-request latency can reorder the standalone GET SSE stream behind a tools/call POST. If the tool handler fires before the GET stream is established at the workload, the server-initiated request has no stream to ride and the client times out (~60s).

Evidence

Surfaced via the tools-call-sampling MCP conformance scenario (intermittent 60s client timeout in CI). Cold-start comparison (fresh stack per iteration):

  • Direct to the container (no ToolHive): 0 failures.
  • Through the Squid ingress (Go transparent proxy bypassed): ~1/3 failures.

Adding standby=2 to the ingress cache_peer took the squid tier to 0/24 across fresh cold-start runs, and the full conformance job went green.

Fix

Add standby=2 to the ingress cache_peer so Squid maintains warm idle upstream connections; the first request is forwarded without inline connect latency, removing the cold-start ordering skew. Config-only, no acl/http_access change — the inbound-isolation posture is unchanged. This is also standard reverse-proxy hygiene: it reduces cold-start first-request latency for all ingress traffic.

Notes / scope

  • General benefit: lower cold-start first-request latency for every non-stdio workload, plus robustness for MCP servers that use server-initiated messages on the standalone GET stream.
  • Not universal: servers that bind server→client requests to the originating request stream (relatedRequestId) don't hit the race; the complete fix for that pattern is server-side.
  • Separate residual: the Go transparent proxy layer also contributes to the same ordering race under load — under investigation separately, not addressed by this issue.

Activity

  1. added
    needs-triage
    on Jul 20, 2026
  2. self-assigned this
    on Jul 20, 2026
  3. removed
    needs-triage
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions