用 getconf 做基线诊断,再精准调优 Debian 性能
核心思路
快速体检清单与命令
getconf PAGE_SIZE(常见为 4096 字节)getconf CLK_TCK(常见为 100)getconf NAME_MAX /(目录相关)getconf PATH_MAX /getconf OPEN_MAXgetconf SYS_NPROCgetconf THREAD_MAXgetconf LEVEL1_DCACHE_LINESIZE、LEVEL1_ICACHE_LINESIZE、LEVEL2_CACHE_SIZE基于基线的关键调优动作
* soft nofile 65536* hard nofile 65536* soft nproc 4096* hard nproc 4096ulimit -n 65536、ulimit -u 4096ulimit -n、ulimit -u;服务需重启以继承新限制。fs.file-max = 65536net.core.somaxconn = 65535net.ipv4.tcp_max_syn_backlog = 65535net.ipv4.ip_local_port_range = 1024 65535vm.swappiness = 10sysctl -pnoatime,nodiratime(必要时再考虑 discard 或 fstrim.timer 周任务)。sudo systemctl disable --now service_name(逐项确认后再禁用)。sudo apt update && sudo apt install linux-image-amd64;重启后验证 uname -r。sudo apt install htop iotop nmon;观察 CPU、I/O、连接数、句柄使用是否达到瓶颈并回落。应用与开发侧的配合建议
PAGE_SIZE 与 LEVEL*_CACHE_LINESIZE 做数据结构对齐、分块与批处理,减少缓存行抖动与伪共享。OPEN_MAX 与业务 fd 使用模型(连接、日志、管道、mmap 等)设定合理的 worker 数与连接池上限,避免“文件句柄耗尽”。风险提示与回滚
nofile 过多会增大内核内存占用;ip_local_port_range 扩大可能触及防火墙/安全组策略;noatime 可能影响依赖 atime 的备份/审计工具。systemctl revert 或回滚 sysctl -p 前的备份)。