top
查看CPU使用率perf top
查看热点函数pidstat -u
监控特定进程CPU使用nice
和renice
命令taskset
绑定进程到特定CPU核心irqbalance
服务free -m
查看内存使用vmstat -s
查看内存统计pmap -x <pid>
查看进程内存映射sysctl vm.swappiness=10
echo never > /sys/kernel/mm/transparent_hugepage/enabled
/proc/<pid>/oom_score_adj
iostat -x 1
查看磁盘I/Oiotop
查看进程I/O使用dmesg | grep -i "i/o"
查看I/O错误echo deadline > /sys/block/sda/queue/scheduler
noatime,nodiratime
blockdev --setra 1024 /dev/sda
netstat -s
查看网络统计ss -s
查看套接字统计ethtool -S eth0
查看网卡统计bash
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.core.somaxconn=4096
ethtool -L eth0 combined 8
ifconfig eth0 mtu 9000
# 文件描述符限制
sysctl -w fs.file-max=1000000
ulimit -n 1000000
# 网络相关
sysctl -w net.ipv4.tcp_max_syn_backlog=8192
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.tcp_max_tw_buckets=2000000
/etc/security/limits.conf
/etc/systemd/system.conf
性能调优是一个持续的过程,需要根据实际负载变化不断调整。建议每次只调整一个参数并观察效果,避免同时修改多个参数导致难以确定影响源。