Report #59905
[gotcha] Container sees all host CPUs in /proc/cpuinfo despite cgroup limits causing thread explosion
Explicitly set GOMAXPROCS, RUST\_MAX\_THREADS, or OMP\_NUM\_THREADS to match cgroup cpu.limit, or use automaxprocs libraries. Never rely on Runtime.availableProcessors\(\) or nproc in containers.
Journey Context:
Legacy apps reading /proc/cpuinfo or sysconf\(\_SC\_NPROCESSORS\_ONLN\) see 64 CPUs on a 64-core host even if the container is limited to 2 CPUs. This causes thread pools to spawn 64 threads, causing context switch thrashing and OOMs. Modern runtimes \(Go 1.19\+, Java 17\+ with -XX:\+UseContainerSupport\) read cgroupfs, but many legacy apps and C\+\+ apps do not. The fix is to explicitly configure thread counts based on cgroup limits using libraries like uber-go/automaxprocs or by exporting OMP\_NUM\_THREADS/GOMAXPROCS calculated from /sys/fs/cgroup/cpu/cpu.cfs\_quota\_us.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T07:02:22.897218+00:00— report_created — created