在 Debian 系统中,进程负载高通常不是单一问题,而是 CPU、内存、IO、进程配置或内核参数等多方面的综合结果。下面按「定位 → 分类优化 → 系统级调优」的思路给你一套实用方案。
top
htop
uptime
关注:
vmstat 1
iostat -x 1
us 高 → CPU 计算型wa 高 → 磁盘 IO 瓶颈si/so 高 → 内存不足,在 swapps -aux --sort=-%cpu | head
ps -aux --sort=-%mem | head
常见原因
优化方式
cpulimit -p PID -l 50
nice / renicerenice +10 -p PID
worker_processes auto;
查看
free -h
cat /proc/meminfo
优化
systemctl disable xxx
sysctl vm.swappiness=10
[Service]
MemoryLimit=512M
查看
iotop
优化
noop / deadline 调度器(SSD)echo deadline > /sys/block/sda/queue/scheduler
vm.swappiness=10
net.core.somaxconn=65535
net.ipv4.tcp_tw_reuse=1
fs.file-max=100000
sysctl -p
ulimit -n 65535
/etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
systemctl list-unit-files | grep enabled
有时 load average 高,但 CPU 很低:
ps -aux | awk '$8 ~ /D/'
# 找出最耗 CPU 的进程
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
# 临时降优先级
renice 19 -p PID
# 实在不行
kill -15 PID
如果你愿意,可以告诉我:
cat /etc/os-release)我可以给你针对该服务的精准优化方案。