在 Debian 上“进程负载高”通常分几种情况:CPU 占用高、IO 等待高、内存不足导致频繁 swap。下面按排查 → 定位 → 降低负载的思路给你一套实用方法。
top
# 或
htop
重点看:
load average:1/5/15 分钟负载%Cpu(s):
us 高 → 用户进程吃 CPUsy 高 → 系统调用多(可能是程序或驱动问题)wa 高 → IO 等待(磁盘/网络)MEM / SWAP:是否内存不够ps -eo pid,ppid,cmd,%cpu,%mem --sort=-%cpu | head
ps -eo pid,cmd,%mem --sort=-%mem | head
iotop
(需安装:apt install iotop)
strace -p <pid>
可能原因
处理
# 临时降低优先级
renice +10 -p <pid>
# 必要时限制 CPU(cgroups)
apt install cgroup-tools
或干脆:
kill -9 <pid>
⚠️ 若是未知进程 + CPU 异常高,先查是否中毒:
netstat -antp
ls -l /proc/<pid>/exe
常见原因
处理
# 查看哪个进程在写
iotop
# 查看磁盘状态
iostat -x 1
smartctl -a /dev/sda
优化方向:
noatime 挂载表现
处理
free -h
swappinesssysctl vm.swappiness=10
(永久:/etc/sysctl.conf)
[Service]
CPUQuota=50%
MemoryLimit=512M
然后:
systemctl daemon-reload
systemctl restart xxx
worker_processespm.max_childrenmax_connectionssystemctl list-unit-files --type=service | grep enabled
关掉明显用不到的(如 bluetooth, cups)
# 找出最吃资源的进程
ps -eo pid,%cpu,%mem,cmd --sort=-%cpu | head
# 限流
kill -STOP <pid> # 暂停
kill -CONT <pid> # 恢复
你可以补充:
top 截图或输出我可以直接告诉你该改哪个配置、怎么改最安全。