大网数据广告活动
服务器运维问答

High swap usage on Ubuntu server

· 52CE 我爱测

This is what the free command reports on a server that is running a Spring Boot application behind an Nginx reverse proxy: $ free -h total used free shared buff/cache available Mem: 1.9Gi 893Mi 164Mi 29Mi 919Mi 883Mi Swap: 511Mi …

问题原文

原帖链接 · geschema · CC BY-SA 4.0

This is what the free command reports on a server that is running a Spring Boot application behind an Nginx reverse proxy:

$ free -h

               total        used        free      shared  buff/cache   available
Mem:           1.9Gi       893Mi       164Mi        29Mi       919Mi       883Mi
Swap:          511Mi       481Mi        30Mi

How should I interpret the high swap usage? Is that a sign that I should upgrade the server to a higher memory capacity (e.g. 4 GiB)?

Output of vmstat

$ vmstat 1 5

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 493428 150620  95476 879668    0    1     8    28    1    0  3  1 95  0  1
 0  0 493428 150620  95476 879708    0    0     0     4  970 1891  4  1 95  0  0
 1  0 493428 150620  95476 879712    0    0     0     0  851 1708  6  6 86  0  3
 2  0 493428 150620  95476 879712    0    0     0     0  704 1398  4  5 91  0  0
 1  0 493428 150620  95476 879712    0    0     0    16  583 1206  3  3 94  0  0

已采纳解答

原帖链接 · Romeo Ninov · CC BY-SA 4.0

As you can see from vmstat output you do not have si or so activities, even the average (first line) is negligible. Try to play with swappiness but if you do not see serious performance degradation you do not need to change anything.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-08-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。