Skip to content

fix(prober): stop the mesh_dns SLI measuring the prober's own CPU quota (#735) - #738

Merged
bpalermo merged 2 commits into
mainfrom
fix/735-mesh-dns-tier-latency
Sep 6, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/735-mesh-dns-tier-latency

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Fixes #735.

The attribution

tier="mesh_dns" reported p50 179 ms (aether.internal target) / 196 ms (svc.cluster.local target) with 0% under 10 ms, against a mesh-DNS resolver whose server-side p50 is 1 ms and a tier="liveness" p50 of 9 ms. Both DNS targets cost the same although one is answered authoritatively by the node-local resolver and the other is forwarded to kube-dns — so DNS was never the variable.

Measured on talos-main (rev206, 2026-09-06 15:45–16:00Z) from four independent vantage points — the prober's histogram, the source/destination Envoy access logs, a one-shot meshed netshoot Job on main-worker-01 (since deleted), and the kubelet's cAdvisor endpoint. Medians:

layer measured how
mesh-dns resolver, A and AAAA, mesh name 0 ms (aa, ANSWER: 0 for AAAA — already a correct authoritative NODATA) dig +stats ×20
kube-dns forward path, A and AAAA 0–3 ms dig +stats ×20
full client-side resolution 0 ms getent ahosts ×10
fresh TCP connect + HTTP to the local egress direct_response 1.8 ms (p90 2.8) curl ×20
warm-connection version of the same 0.9 ms curl
the mesh hop, as the source proxy itself times it 29 ms (p90 42, p99 62), upstream_service_time 27 ms access log, reporter:"source", n=24,129
... of which the destination proxy + echo app 3 ms (upstream_service_time 1 ms) reporter:"destination", n=24,121
the prober's own number 179 / 196 ms aether_probe_request_duration_seconds

Source-proxy duration is 29 ms for both DNS targets and 28–30 ms on all five nodes.

179 − 29 = ~150 ms is outside the proxy and outside DNS. It is the prober being CFS-throttled by its own chart. limits.cpu: 50m is a 5 ms budget per 100 ms period, and off the kubelet's cAdvisor endpoint (cAdvisor is not scraped into Prometheus here, which is why this stayed invisible until #733 fixed the buckets):

node pod periods throttled % throttled throttled seconds (pod life ≈ 4,000 s)
main-worker-01 prober-2w6fx 40,070 34,621 86.4% 3,916 s
main-worker-02 prober-hvxnx 39,581 35,685 90.2% 2,285 s
main-worker-03 prober-ffc5r 39,813 32,240 81.0% 2,882 s
main-worker-04 prober-pc8gf 40,223 32,971 82.0% 1,055 s
main-worker-05 prober-2c48t 40,477 33,438 82.6% 1,922 s

kubectl top: 44–48 m on every pod — pinned at the quota. Once the quota is gone the runnable goroutine sleeps to the next period boundary, so probe latency comes out quantised in ~100 ms steps: exactly the 0% ≤ 10 ms / 21% ≤ 100 ms / 73% ≤ 250 ms distribution in the issue, exactly a median of ~1.75 periods.

The same throttle inflates the control: the liveness tier's 9 ms p50 / 317 ms p99 is a local direct_response that an unthrottled client in the same pod network measures at 0.9 ms warm / 1.8 ms fresh. A local reply cannot take 317 ms on any network.

The CPU goes where the tier's design puts it. aether_mesh_dns_queries_total confirms the tier really does resolve every probe (qtype=a,result=answered 25.09/s and qtype=aaaa,result=nodata 25.10/s = 5/s × 5 nodes, one A and one AAAA each), and Pyroscope {k8s_container_name="prober"} puts 21.5% of the whole process in net.(*Resolver).tryOneName and 17.7% in http.(*Transport).dialConn (→ internetSocket 13.9%, netFD.dial 9.7%).

All three candidates on the issue are answered: (1) AAAA is fine — answered locally, authoritatively, NODATA, in 0 ms; (2) the fresh connection per probe is real but costs 29 ms, not 170; (3) no search-list expansion — ndots:2, both names carry 3 and 4 dots, one A + one AAAA per probe.

The change

charts/prober/values.yaml (chart 0.2.0 → 0.3.0) — requests.cpu: 100m and no CPU limit. A limit is a quota, and the one workload that must never measure its own scheduling is the one that publishes the latency SLI. The prober is open-loop and rate-bounded (probe.rate × targets) so it cannot run away; the memory limit stays (it also feeds GOMEMLIMIT). The values comment says to re-add limits.cpu only with a quota that cannot bind (≥ 1), never a fraction of a core.

prober/internal/prober/prober.go

  • The mesh_dns tier gets its own DisableKeepAlives transport. It must resolve on every probe — that IS the SLI (P1: mesh DNS resolution broken for managed pods on rev 175 (masked by DNS-bypassing prober) #574) — and Go resolves only when it dials. That held before only by accident: probe() closed resp.Body without draining it, which is itself enough to make Go destroy the connection. Stating it means the tier survives an upstream that answers with no body (as the liveness direct_response does) and it no longer leaks onto tiers that want reuse.
  • Drain the body before closing it, so the keep-alive tiers actually keep alive. The liveness tier only escaped the old behaviour because a direct_response carries no body; the (currently unconfigured) reachability tier, documented as reusing the fixed egress, would have silently connected per probe. The drain happens after the clock stops, so the metric still means time-to-response-headers.

Tests — TestTierClients pins which transport each tier uses; TestProbeConnectionReuse asserts on the wire that a keep-alive tier opens 1 connection over 4 probes and the mesh_dns tier opens 4, against a server that answers with a body (verified to fail with the old bare Close()); TestDrainBody pins the EOF postcondition Go's pooling depends on.

Not changed: the other 29 ms

connection_pool_per_downstream_connection: true on every node-proxy service cluster (agent/internal/xds/proxy/egress.go:213), deliberately, so one source pod's upstream connection and its client certificate are never reused for another source. Measured on w01 over 5 minutes: 2,028 requests, 1,981 downstream connections, 1,869 upstream connections — no pooling across downstream connections. So each new client connection pays a fresh cross-node TCP + mTLS handshake: source upstream_service_time 28 ms against a destination-side total of 3 ms, i.e. ~25 ms of handshake per new connection, uniform across clusters (echo 29 ms, uds-echo 22 ms, uds-cr-echo 22 ms) and across nodes including those hosting a local replica.

That is the price of the per-source-identity model, not a defect, and the proxy is untouched here. Two follow-ups worth their own issues: 25 ms is high for a LAN handshake and the destination inbound's accept path deserves a look; and any future latency objective on this SLI must be stated per-connection, not per-request, because the happy path is a connection-establishment benchmark by design.

Expected after deploy

series now expected
mesh_dns p50, both targets 179 / 196 ms ~30–35 ms (the 29 ms proxy-observed hop + ~1–3 ms DNS + ~1 ms dial; the unthrottled curl control measured 31.4 ms with DNS bypassed and 28.5 ms via the egress)
liveness p50 9.05 ms ~1–2 ms
liveness p99 317 ms low tens of ms
CFS periods throttled 81–90% 0%
# the SLI itself
histogram_quantile(0.5, sum by (tier, target, le) (rate(aether_probe_request_duration_seconds_bucket[10m])))
histogram_quantile(0.99, sum by (tier, target, le) (rate(aether_probe_request_duration_seconds_bucket[10m])))

# the fraction of probes that now land under 10 ms (was 0 for mesh_dns)
  sum(rate(aether_probe_request_duration_seconds_bucket{tier="mesh_dns", le="0.01"}[10m]))
/ sum(rate(aether_probe_request_duration_seconds_count{tier="mesh_dns"}[10m]))

# the prober must stay unthrottled; cAdvisor is NOT scraped into Prometheus on
# talos-main, so read it off the kubelet:
#   kubectl get --raw "/api/v1/nodes/<node>/proxy/metrics/cadvisor" \
#     | grep -E 'container_cpu_cfs_(periods|throttled_periods)_total\{container="prober"'
# throttled/periods must be ~0.

# the mesh hop should be unchanged at ~29 ms — this change must not move it
# (VictoriaLogs LogsQL, source reporter):
#   authority:"echo.aether-test.aether.internal:18081" reporter:"source"
#     | stats quantile(0.5, duration_ms) dur_p50, quantile(0.5, upstream_service_time) ust_p50

Refs #733 (buckets), #728 (resolver options), #574 (the blind spot the tier closes).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 6, 2026 13:10
…ta (#735)

The mesh_dns tier reported a p50 of 179 ms (kube target 196 ms) with nothing
under 10 ms, against a mesh-DNS resolver whose server-side p50 is 1 ms and a
liveness tier at 9 ms. Both DNS targets cost the same although one is answered
authoritatively on-node and the other is forwarded to kube-dns, so DNS was
never the variable.

Attribution on talos-main (rev206, 2026-09-06, medians):

  mesh-dns resolver, A and AAAA, either name           0-3 ms
  fresh conn + HTTP to the local egress direct_response  1.8 ms
  the mesh hop as the SOURCE PROXY times it             29 ms  (n=24,129)
    of which the destination proxy + echo app            3 ms  (n=24,121)
  the prober's own number                              179 ms

The ~150 ms between the proxy's 29 ms and the prober's 179 ms is the prober
being CFS-throttled by its own chart. `limits.cpu: 50m` is a 5 ms budget per
100 ms period; the container was throttled in 81-90% of ALL periods on every
one of the five nodes (cAdvisor, read off the kubelet - it is not scraped into
Prometheus, which is why this stayed invisible), so probe latency came out
quantised in ~100 ms steps. The same throttle inflates the liveness tier: an
unthrottled client measures that local direct_response at 0.9 ms warm / 1.8 ms
fresh, not 9 ms p50 / 317 ms p99.

The CPU goes where the tier's design puts it: mesh_dns resolves and dials on
every probe, and Pyroscope puts 21.5% of the process in
net.(*Resolver).tryOneName and 17.7% in http.(*Transport).dialConn.

So:

- charts/prober: request 100m and NO cpu limit. A limit is a quota, and the
  one workload that must never measure its own scheduling is the one that
  publishes the latency SLI. The prober is open-loop and rate-bounded, so it
  cannot run away; the memory limit stays (it feeds GOMEMLIMIT).

- prober: give the mesh_dns tier its own DisableKeepAlives transport. It must
  resolve on every probe - that IS the SLI (#574) - and Go resolves only when
  it dials. That was true before only by accident: probe() closed resp.Body
  without draining it, which is itself enough to make Go destroy the
  connection. Stating it means the tier survives an upstream that answers with
  no body, and it stops silently applying to tiers that want reuse (the
  liveness tier escaped only because a direct_response carries no body; the
  reachability tier, documented as reusing the fixed egress, did not).

- prober: drain the body before closing it, so the keep-alive tiers actually
  keep alive. Draining happens after the clock stops, so the SLI still measures
  time-to-response-headers.

Not changed, but now measured and worth stating: 25 of the mesh hop's 29 ms is
a fresh upstream mTLS handshake, because the node proxy's clusters set
connection_pool_per_downstream_connection (deliberately - one source pod's
upstream connection, and its client certificate, must never be reused for
another source). Over 5 minutes on one node: 2,028 requests, 1,981 downstream
connections, 1,869 upstream connections. A mesh client that does not reuse its
connections pays a full handshake per request; that is the price of the
per-source-identity model, not a defect, and the proxy is untouched here.

Expected after deploy: mesh_dns p50 ~30-35 ms (the proxy-observed hop plus
DNS plus a dial), liveness p50 ~1-2 ms, throttled periods ~0%.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit f81a16c into main Sep 6, 2026
18 checks passed
@bpalermo
bpalermo deleted the fix/735-mesh-dns-tier-latency branch September 6, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant