Repository navigation
Commit 20545d0
committed
fix(tcp-balancer): cap HAProxy fds and threads by the pod's own limits
Without a global section HAProxy 3.4 sizes itself from the node.
maxconn comes from the nofile limit, cut to the built-in fd-hard-limit
of 1048576, so about 524k, and the thread count is the number of CPUs
the process may run on, whatever the CPU limit says. With one thread
that alone idles at about 85 MiB, and every thread adds about 0.6 MiB,
so a t1.nano replica with its 128Mi limit runs on a small node and is
OOMKilled at startup on a node with many CPUs.
fd-hard-limit is now 32 per MiB of the memory limit, from which HAProxy
derives about 16 connections per MiB, 2035 for the t1.nano defaults.
That leaves 64 KiB per connection against the roughly 35 KiB HAProxy
budgets per connection itself when it is given a memory limit with -m,
and the rest covers the process and the kernel socket buffers charged
to the same cgroup. It caps the derived value instead of setting
maxconn, because an explicit maxconn above half the hard nofile limit
stops HAProxy at startup (strict-limits is on by default), while
fd-hard-limit still follows a lower system limit.
thread-hard-limit is the CPU limit rounded up, at least 1. It only caps
the detected thread count, so a node with fewer CPUs is not forced to
run more threads than it has.
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <[email protected]>1 parent 1f92bcd commit 20545d0
2 files changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
0 commit comments