IT

Why Linux shows 80% CPU pressure while Docker containers idle

An in-depth look at Linux and Docker resource quotas: why PSI shows high pressure even when CPU usage and host load remain low.

·2 min read
Why Linux shows 80% CPU pressure while Docker containers idle

The author recently decided to test how many isolated Linux environments a modest VPS with 3 vCPU and 6 GB of RAM could simultaneously handle. The setup used Docker and gVisor for isolation, running an educational project that spawns environments with pre-configured system flaws. The initial goal was to see if the server could withstand nine concurrent instances, but the experiment revealed a fascinating anomaly.

  • Server CPU was idle 98–100% of the time on short intervals.
  • Linux pressure stall information (PSI) nevertheless showed nearly 80% CPU pressure.
  • A specific load test container consistently consumed about 25% of a single CPU core.
  • Cgroup v2 metrics confirmed continuous throttling during the observation period.

Analyzing Container Resource Constraints and Quotas

After launching a gaming container, resources stabilized until an additional high-load scenario was introduced. This container steadily consumed around a quarter of a CPU core. However, overall server load remained relatively low, with vmstat reporting between 61% and 91% CPU idle time. This created a paradox: why were tasks frequently waiting for CPU cycles when the VPS itself was far from overloaded?

The answer lay in resource quota enforcement. The container was permitted to use 25,000 microseconds of CPU time per 100,000 microsecond period. Inspecting cgroup v2 statistics via cpu.stat and cpu.pressure revealed that out of 103 observed quota periods, throttling occurred in every single one. The container exhausted its allocated limit even though free CPU time was readily available on the host machine.

Read alsoTurning an Android TV Box into a Linux Mini Server

Understanding the Difference Between CPU Usage and PSI

Pressure Stall Information (PSI) measures the duration tasks spend waiting for resources rather than raw CPU utilization. Free CPU time on the host does not automatically mean a constrained container can utilize it. The tasks were ready to continue execution, but the hard quota boundary had already been reached, forcing them to wait.

Once the intensive load scenario was terminated, the immediate pressure dropped, though longer-term rolling averages like avg60 and avg300 remained elevated. In this educational project, CPU throttling acts as an expected protective safeguard preventing a single faulty environment from starving other workloads. However, monitoring tools must account for this behavior.

Practical Takeaways for System Diagnostics and Monitoring

This investigation demonstrates that relying solely on top or docker stats can be misleading when diagnosing containerized workloads. A high PSI metric does not necessarily indicate that a server requires physical hardware upgrades or more cores. Often, the bottleneck stems strictly from local cgroup configurations.

For accurate troubleshooting, administrators should routinely examine parameters such as cpu.max, cpu.stat, and cpu.pressure alongside traditional metrics. This comprehensive approach ensures correct identification of performance bottlenecks and helps evaluate how resource limits impact overall user responsiveness.

Source: Все публикации подряд на Хабре

Related articles