Repository navigation
Description
Bug description
One backend whose real round-trip latency merely hovers in the 10-25s
range (not down, not erroring - confirmed via direct measurement: DNS/TCP/
TLS all under 100ms, 100% of the delay is upstream server-processing time)
took its entire VirtualMCPServer tenant's client-facing initialize
success rate to ~50% for the better part of an hour, across two full
pod-restart cycles, with no self-healing. The tenant's other 18 backends
are healthy and aggregate in ~1s.
Steps to reproduce
- Configure a VirtualMCPServer with N fast/healthy backends + 1 backend
whose real response time is consistently in the 10-25s range (a real
network hop to a genuinely slow-but-working upstream - natural variance
matters, a synthetic fixed delay won't reproduce the flapping). - Send
initializefrom a fresh client/session repeatedly (5-10
consecutive attempts, not one sample - a single request can land in
either a favorable or unfavorable window). - Observe the success rate and timing distribution.
Expected behavior
A backend that is merely slow (not down) should not be able to drag an
entire tenant's client-facing success rate to a coin flip. Per #3036
(closed), health monitoring + circuit breaker + partial-failure-mode
(best_effort) already exist as designed features for exactly this kind
of scenario.
Actual behavior
- Two independent operators each ran 5-7 consecutive
initializecalls
against the same tenant over ~1 hour, with two restart cycles (the slow
backend's own proxy pod, then the vmcp pod) in between: results were a
mix of503/timeout-after-~30s and200after anywhere from 2.8s to
26s - both failures and slow successes recurring throughout, no stable
trend within either restart's lifetime. - Root-caused to NOT be a stuck/wedged state clearable by a restart:
watched the slow backend's freshly-restarted proxy with zero external
client activity, and the samecontext canceledrecurred at T+28s,
driven purely by vmcp's own background health-monitor. Separately, a
freshly-restarted vmcp pod showed the identical failure on its very
first attempt to reach this backend. operational.timeouts/operational.failureHandling(default/
per-workload timeouts, healthCheckInterval/healthCheckTimeout, circuit
breaker, partialFailureMode) were unset on our VirtualMCPServer, i.e. we
were running on compiled-in defaults. We saw no indication the circuit
breaker was actually open/engaging for this backend despite it being
flagged unhealthy/degraded repeatedly - every new session's blocking
per-backend init still re-attempted the connection and re-paid close to
the full timeout, rather than the health monitor's already-known-bad
status short-circuiting it.- Backend health status flapped
unhealthy -> degraded -> unhealthy -> degraded -> ...continuously over many minutes (observed a 5s
"degraded" threshold:"health check succeeded but response was slow - marking as degraded", duration=7.86s, threshold=5s), tracking the
backend's real latency bouncing around that internal threshold. - Some sessions received
session capabilities injectedwith no
per-backend attempt logged at all for the slow backend - some kind of
aggregated-capability caching across sessions (matches the per-session-
snapshot architecture described in vMCP: backend health/set changes are not propagated to live sessions (stale tool catalog until reconnect; no tools/list_changed) #5786,caching_aggregator.goet
al). But whenever the backend's status flipped, the next new session
paid the full cost again - this only makes the failure rate
probabilistic, not fixed. - A structurally similar pattern (synchronous per-session blocking work
racing a client timeout, reconnect storm as the failure compounds) is
independently reported in a different vmcp subsystem in vMCP optimizer re-embeds the full tool set on every session (Serve path) — unreliable at scale, tools/list blocks on the rebuild #5847
(embedding-optimizer re-embed-per-session).
Follow-up: ruled out simple "cold start" as the backend-side cause
Wanting to know whether the slow backend itself was a classic serverless
cold-start (which would suggest a pre-warm keepalive as a workaround), we
checked two things directly against it:
- Response headers show no serverless-platform signature. A full
header dump from a realinitializeagainst it:Cloudflare here is just the edge/CDN. No Vercel/AWS-Lambda-API-Gateway/server: cloudflare cf-ray: <redacted> x-powered-by: Express x-clerk-auth-reason: session-token-and-uat-missing x-clerk-auth-status: signed-out
Fly.io/Render request-id header of any kind - the origin self-identifies
as a persistent Express (Node) process, not a FaaS. Interestingly, a
third-party auth/identity platform (Clerk) is in the request path on
every call, even ones authenticated via a static API key rather than
its own session flow - raising the possibility that the variable latency
is a synchronous per-request round-trip to that dependency rather than
compute cold-start, though we can't confirm this without visibility into
the backend's own internals. - No warming trend across repeated calls. 10 consecutive samples
(~5-10s apart, not spread across hours): 23.9, 23.6, 15.5, 17.7, 10.7,
16.6, 19.6, 17.4, 12.8, 10.5s. Classic cold-start would show request Do we want the container monitor? #2
onward collapsing to sub-second once "warm" - it never did, even by
sample Implement secrets management #10. A second operator's independent sample saw three
back-to-back complete hangs to a 20s client timeout on the same
backend. This looks like persistent per-request instability, not
"slow once then fast," which argues against a pre-warm-keepalive
workaround being effective and reinforces that this is a real-world
failure mode vMCP needs to tolerate (slow third-party backends are a
normal occurrence, not an edge case).
Environment
- ToolHive operator + vmcp: v0.34.0
- Single-node Kubernetes (Talos)
Additional context
- Related: Add health monitoring and circuit breaker to vMCP server #3036/Add health monitoring and circuit breaker to vMCP server #2853 (closed) added health monitoring + circuit
breaker - this may be a gap in how per-session blocking init interacts
with that already-implemented state, rather than a request for a wholly
new feature. - Related: vMCP: backend health/set changes are not propagated to live sessions (stale tool catalog until reconnect; no tools/list_changed) #5786 (open) - same per-session capability-snapshot/caching
architecture, inverse angle (existing sessions go stale when a backend
recovers; here, new sessions still pay full cost against a backend
already known-flaky and can lose the race against realistic client/
gateway timeouts). - Workaround in place: removed the slow backend from the tenant's group
(our topology uses opt-in group membership) - not a fix, and not
available to deployments with a flat/explicit backend list. We
considered raisingoperational.timeouts.perWorkloadfor just this
backend, but since its own worst-case latency is 15-25+s (sometimes a
full hang), doing so would only convert "occasional hard failure" into
"every session against this tenant reliably takes 15-25s" - not
something we're willing to trade for keeping one backend's tools, but a
real option depending on the use case. - Suggested directions: (a) verify whether circuit-breaker state actually
gates the per-session blocking-init path, not just the background
health-check path; (b) make "backend already known bad, skip
re-attempting this session" the default once unhealthy/degraded,
re-testing only on the health-monitor's own schedule; (c) make the
capability-aggregation cache (if that's genuinely what's happening)
explicit/documented - right now its presence or absence is the
difference between a tenant working and being a coin flip.
Activity
jerm-dro commentedon Aug 5, 2026
Thanks for the unusually thorough report — the direct latency measurements and the ruled-out-cold-start follow-up made this much faster to confirm. Picking it up; assigned to me.
(a) You were right. Circuit-breaker state gated only the background health-check loop, never per-session init —
CanAttempt()had exactly one production caller, the monitor's own loop. Session creation listed backends unfiltered and blocks on every one it attempts. Health gated capability aggregation but never connection establishment, and establishment runs first.(b) Implemented in #6162. Session establishment now skips known-bad backends by default, no config needed. Your instinct to include degraded and not just unhealthy was load-bearing: your backend's latency straddles the 5s degraded threshold and 10s probe timeout, so it oscillates — skipping only
unhealthywould have left the coin flip intact. Tools stay advertised and callable; only the blocking connect is skipped.Worth knowing: the regression test shows the handshake makes four sequential round trips per backend, each paying full latency. A 2s backend costs 8s of session creation — so yours was costing far more than 25s against a ~30s timeout, which is why you saw hard failures rather than just slow ones.
operational.timeouts.perWorkloaddoes nothing. You considered raising it and rejected the tradeoff — sound reasoning, but moot: the field is validated, defaulted, in the CRD, documented, and read by no code. Same forpartialFailureMode, which is why "these already exist as designed features" was only half true. Filed as #6164.Not addressed: your (c) — the capability cache (30s TTL, per-identity) is real and still undocumented. And there's no hysteresis on those thresholds, so the flapping itself continues; #6162 stops it hurting clients but doesn't damp it.
One caveat: #6162 doesn't cover the window before the first health check completes. On a freshly restarted pod the status isn't known yet, so early sessions can still block (up to ~60-90s if the first probe times out) — matching your "failed on its very first attempt after restart" note. Steady state is fixed; the restart case is narrowed, not eliminated. #6162 carries
Fixes #5861so it'll auto-close on merge — flagging that so the remaining gap isn't a surprise. Wiring the timeout in #6164 would bound it.Your group-removal workaround should become unnecessary once #6162 lands, except briefly after a restart.
chore(toolhive): 0.42.0 -> 0.42.1 for the slow-backend session fix (#…
RaviTharuma commentedon Aug 15, 2026
Residual on v0.43.0 (not asking to reopen unless you want it)
#6162 clearly improved the old ~50% coin-flip. On v0.43.0 we still saw one client
initializeagainst a Ready vMCP time out at 12s with 0 bytes; the next call to the same path returned 200 in ~3s. CR Ready, alldiscoveredBackendsready, breakers closed.Filed as a leftover observability / session-open issue rather than reopening this one: #6345.
No credentials or private hostnames.