
How a default AWS AMI setting created thousands of zombie cgroups that paralyzed an ML cluster
This article details the journey of Pinterest engineers as they dive into kernel-level profiling to solve mysterious network failures in their Ray ML cluster. It reveals how what seemed like a simple networking error was actually a complex CPU starvation issue caused by tens of thousands of zombie memory cgroups, offering deep insights for infrastructure engineers.
Never trust default cloud vendor AMI settings blindly. If you encounter inexplicable performance degradation, don't rely on average CPU metrics; instead, perform per-core profiling and check for kernel system call latencies.
Ray-based ML training jobs at Pinterest experienced intermittent crashes due to network connectivity loss and ENA driver resets, particularly on GPU instances in a specific AWS availability zone. The issue was correlated with high system CPU usage and page faulting, but standard memory optimizations failed to resolve the problem.
Using mpstat for per-core monitoring and Flamescope with time-traveling perf profiles, the team identified that the Kubelet was pinning a single CPU core at 100% while executing the mem_cgroup_nr_lru_pages system call. The root cause was discovered to be tens of thousands of 'zombie memory cgroups' created by a crashing ecs-agent, a default systemd unit in the AWS Deep Learning AMI, which was subsequently disabled.
By eliminating the CPU starvation caused by zombie memcgs, the team restored the stability of ML training jobs and stopped the loss of expensive GPU compute hours. The investigation also highlighted the critical need to audit default configurations in cloud vendor-provided machine images.
Trade-off
The investigation spanned over three months, involving significant resource expenditure on ineffective initial hypotheses like Huge pages and alternative memory allocators. Resolving the issue required manual intervention to disable default system services, adding a minor layer of configuration management overhead.
AWS's next-generation network interface driver that triggers a hardware reset if the CPU fails to respond within a specific threshold (e.g., 5 seconds).
Memory control groups that remain in the kernel after a container or process exits because some memory references are still active.
A performance visualization tool developed by Netflix that breaks down profile data into sub-second intervals to track intermittent latency spikes.




