Commit 386dad7
fix(container-cache): size nginx workers from the CPU limit, not the host
worker_processes was `auto`, which makes nginx call
sysconf(_SC_NPROCESSORS_ONLN). That reports every core on the host and is blind
to the cgroup quota, so a pod with a CPU limit well below the node's core count
starts several times more workers than it can ever run. Observed in production:
about 128 worker processes against a 32 core limit on a 128 vCPU node.
It does not usually show up as sustained throttling, and did not here: the
measured throttled-period ratio was under 0.004 percent. The costs are
elsewhere.
- Memory. Each worker preallocates its own worker_connections structures, so
that footprint is multiplied by the host core count rather than by the quota.
- Upstream keepalive. Pools are per worker process, so more workers than the
pod can schedule fragments every pool and defeats connection reuse, including
the peer-hop reuse added alongside this.
- Burst latency. Many runnable workers drain the quota well before the 100ms
CFS period ends, so a burst becomes a multi-second stall rather than a small
slowdown. One pod showed 431 seconds of throttled time across only 47
throttled periods, which is about 9 seconds per event.
Derive it from resources.limits.cpu, with cache.workerProcesses as an override.
Both plain-integer and milliCPU limits are handled, sub-core limits floor to one
worker rather than zero, and no limit at all still falls back to auto, which is
the one case where the host count is the correct answer.
worker_connections is unchanged. It is a per-worker figure and its current value
was raised deliberately.
Tests: adds tests/chart-render/verify-worker-processes.sh covering the default
derivation, an explicit override, milliCPU conversion, the sub-core floor,
integer-typed limits, the no-limit fallback, and that worker_connections is left
alone. Verified the suite fails when the derivation is reverted to auto.
Relates to #1037
Co-Authored-By: Balaji Ganesan <bganesan@nvidia.com>1 parent 3a84e0f commit 386dad7
3 files changed
Lines changed: 87 additions & 1 deletion
File tree
- deploy/helm/container-cache
- deploy
- files
- tests/chart-render
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
18 | 44 | | |
19 | 45 | | |
20 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments