Why free, docker stats and ps disagree about memory on your VPS (measured on a 1 GB box)
Описание и применение
На 1 ГБ VPS разные инструменты (free, docker stats, ps) показывают разные значения памяти, потому что они измеряют разные вещи. free’s available — лучший индикатор готовности к нехватке, docker stats игнорирует swap, а RSS/PSs дают разные представления о потреблении процессов.
Задача
Different system tools report conflicting memory usage on a 1 GB VPS, leading to misinterpretation of resource consumption.
Результат
The article demonstrates that free’s available column, docker stats, ps RSS, and PSS each measure different aspects of memory, and that misreading them can lead to under‑ or over‑provisioning of RAM.
Рабочий процесс
- 1. Run
free -mto view used, available, and swap usage. - 2. Run
docker stats --no-streamto sum container RAM (excluding swap). - 3. Sum RSS from
psor/proc/<pid>/smaps_rollupfor per‑process view. - 4. Sum PSS from
/proc/<pid>/smaps_rollupfor accurate process cost. - 5. Read cgroup files
/sys/fs/cgroup/.../memory.currentandmemory.swap.currentfor each container. - 6. Use
vmstat 1 5to monitor swap I/O and kernel activity.
Доказательства
They count different things. free reports the whole machine, and its available column (192 MB here) is the one that tells you how close you are to trouble.
docker stats added up to only 343 MB because it leaves out swap and the cache the kernel can drop: n8n showed 24.6 MiB while another 195 MB of it sat in swap.
RSS is every page a process has in RAM, including pages it shares with others: libraries, and memory a parent process shares with its workers.
PSS is the same pages, with each shared page split between the processes sharing it.
The kernel's own estimate of what is still usable, MemAvailable, was 192 MB, and that is what free prints as available.
- Дата записи: 2026-10-10T15:56:03.509Z