Skip to content

config(listen): D0b — scale prod listen on CPU 55%, socket guards 16 req / 35 ws per pod - #22934

Merged
Git-on-my-level merged 2 commits into
mainfrom
config/listen-hpa-cpu-d0b
Oct 20, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
config/listen-hpa-cpu-d0b

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

D0b from plan-d-realtime-gateway.md §1/§5 and cost-gap-plan-2026-10-20.md lever #6. Prod listen now scales on CPU. Before this, only socket metrics drove scaling (22 ws/pod and 10 upgrades/pod). This is a config-only change to prod_omi_backend_listen_values.yaml:

autoscaling key before after
targetCPUUtilizationPercentage (commented out) 55
activeConnectionsPerPod (ws guard) 22 35
requestsPerPod (LB-request guard) 10 16
minReplicas / maxReplicas 40 / 60 unchanged (the lead lowers the floor separately)

Why 55% and not the plan's 70%. The HPA takes the maximum across its metrics and ignores ratios within 10% of target. A target T therefore only scales out once mean CPU exceeds about 1.1×T. During the 2026-10-19 incident (15:10–17:25Z), mean listen CPU per pod peaked at 0.56–0.65 of the 1-CPU request (10-minute means) while the hottest pods saturated. At 70%, and also at 60%, the HPA would never have acted. At 55% it acts above about 0.60, which would have fired in the 16–17Z window. The plan's figure of about 17 pods at p50 assumes about 90% utilization; per-pod CPU is too uneven for that.

Why both socket guards rise together. Raising them is for the later floor drop, not for this roll. Live HPA right now: 14.8 ws/pod (target 22) and 8.8 on backend_listen_requests_per_pod (target 10) at 40 pods. That second metric is every LB response code over a 3-minute window divided by replicas (prod adapter, no 101 filter), so 8.8 means about 117 LB requests a minute in total, not concurrent upgrades. At the old targets the guards would hold about 36 and 27 pods. That is below the floor of 40 today, but it would pin listen near 36 once the floor drops, so CPU could never take over. At 16 and 35 they bind near 22 and 17 pods at today's peak, so they act only on connection or request surges. With the old guards, CPU would still have scaled out at the incident mean (ceil(40 × 0.65 / 0.55) = 48), because the HPA takes the max. Neither guard was dropped. The guards cap the per-pod average; they do not cap the hot pod.

Evidence (ro-prod tier, Cloud Monitoring aggregates only: kubernetes_io:container_cpu_request_utilization for the backend-listen container, kube-state-metrics HPA status, and a kubectl get hpa status read of the metric values only):

  • Last 7 days: mean CPU 0.42 at p50 and 0.62 at p95. Across pods, the p95 pod is at 0.66 at p50. The hottest pod sat at about 2.0 cores (the limit) from 06Z to 18Z on 10-20.
  • Pre-incident week (10-13 to 10-19, floor 12): 28.7 pods at p50.
  • Last 24h (floor 40): mean CPU 0.34 to 0.63. The peak is 16–18Z, with 25 cores across 40 pods.

Expected pod count by hour (UTC)

Computed from the last 24h as mean CPU × replicas ÷ 0.55, rounded up. From N ready pods the HPA moves only when the recommendation leaves ±10% of N. From 40, scale-up needs a recommendation of at least 45. Scale-down then runs at 1 pod per 120s after a 600s window, so 46 → 40 takes about 20 minutes.

hour 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
CPU recommendation 33 35 32 27 27 25 25 29 30 28 30 30 30 35 38 41 43 45 46 36 33 34 33 32
as shipped (floor 40) 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 45 46 40→ 40 40 40 40
  • As shipped (floor 40): 15–16Z sit inside the deadband and stay at 40. 17–18Z go to 45–46, then decay back to 40 within about 20 minutes. That is about 12 extra pod-hours a day, roughly +$1/day, as headroom in the hours that degraded on 10-19. That is all this PR changes on its own.
  • After the lead lowers the floor (for example to 25): about 33 pods mean versus 40 today, roughly −$16/day at today's per-pod CPU. Before lowering, confirm the checked-in prod_omi_backend_listen_cronjob.yaml (which patches the floor to 10 at 01Z and 30 at 11Z) is still not applied. Today kubectl get cronjob -A under ro-prod returns none.
  • Path to the plan's −$25/day: it needs the D0a CPU fix (per-flush re-encode) to cut cores. Cores per hour at peak are about 25% above the pre-incident week.

Rollout and watch

Ship this in an off-peak listen roll that the lead schedules, not together with the STT-routing fix roll, so the two listen changes stay separately attributable. Watch for 24h:

  • Event-loop lag: histogram_quantile(0.99, sum by (le) (rate(omi_listen_event_loop_lag_seconds_bucket[5m]))) < 50 ms. This is the D0b gate in backend/docs/listen_pusher_pipeline.mdx. It lives in the in-cluster Prometheus, not GMP.
  • Session failures: listen session terminal-failure and close-code rates, live STT exhausted/accepted (10-19 baseline 0.25–0.27), and Soniox connection_lost per 10m.
  • First-text latency per arm (feat(stt): measure routing-arm first text at on/100 #22230), plus terminal-after-text.
  • HPA: kube_horizontalpodautoscaler_status_desired_replicas should track the table above. Hottest-pod CPU should stay below the 2-core limit, and liveness/readiness probe timeouts should not reappear.

Known limit: a mean-CPU target does not rebalance a single hot pod; the long-lived sockets stay where they are. That hot pod existed before this change. D0a, or the edge gateway, is the fix for it.

Review

Grok: no blockers. Every should-fix is addressed in the second commit:

  • the deadband-corrected table;
  • the guard rationale and the corrected units for backend_listen_requests_per_pod;
  • the test now pins the reviewed values;
  • the CronJob was checked (not in the cluster);
  • the stale D0b docs are updated;
  • the rollback timing is corrected.

Lane / contract

Lane pusher-d0b (10-20 swarm P5 Part B); owner sign-offs for edits to other lanes' files: none

Product invariants affected

none

Verification

  • backend/test.sh on test_backend_listen_helm_defaults.py: 10 passed. Layer: unit plus a local helm template render.
  • New test test_prod_listen_hpa_scales_on_cpu_with_socket_guards renders the prod chart. It asserts a CPU Utilization metric below 60% and pins the reviewed values: CPU 55, guards 16 and 35, floor and ceiling 40 and 60. The listen_pusher_pipeline.mdx and listen_loop.py text that called the D0b gate "CPU 70%, before the retune" now describes 55% and a 24h watch after the roll and before the floor drop.
  • Not run: any deploy. HPA behavior under load is measured only after the lead's off-peak roll.

Rollback

Revert this PR (targetCPUUtilizationPercentage back to commented out, guards back to 22 and 10) and roll listen. For an immediate effect without a roll, an operator can patch the HPA metrics. The HPA re-evaluates on its next 15s sync. Scale-down still honors the 600s window plus 1 pod per 120s, so 46 → 40 takes about 20 minutes. A chart-only listen upgrade that keeps the running image does not change the pod template, so it updates the HPA without dropping websockets.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 2 commits October 21, 2026 02:15
…req / 35 ws per pod

Listen scaled only on sockets (22 ws/pod) and upgrade rate (10/pod), so pods
sat at about 45% mean of their 1-CPU request off-peak while the 10-19
incident (mean 0.56-0.65, hot pods at the 2-core limit) produced no scale-out
signal at all. CPU becomes the primary metric at 55%, which with the HPA's 10%
tolerance acts above ~60% mean. Both socket metrics stay as guards, raised
22->35 ws and 10->16 req per pod so they bind on connection surges rather than
ordinary load. minReplicas stays 40; the lead lowers the floor separately.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 55% and a post-roll watch

Grok review: the HPA test accepted any CPU target under 60 and any guard
value, so a guard could be raised until it never binds. It now pins CPU 55,
guards 16/35 and min/max 40/60. listen_pusher_pipeline.mdx and listen_loop.py
still described the retune as CPU 70% gated before rollout; they now name 55%
and a 24h lag watch after the roll and before the floor drops.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T20:05:04.109642Z b7fb8e1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 43a13c7 into main Oct 20, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the config/listen-hpa-cpu-d0b branch October 20, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant