---
title: Nginx 高性能与稳态配置(worker、epoll、keepalive、sendfile 与缓存)
keywords:
- Nginx
- worker_processes
- epoll
- keepalive
- sendfile
description: 总结 Nginx 的高性能稳态配置要点,包括 worker/epoll、keepalive、sendfile 与缓存控制,并提供可验证的方法。
date: 2025-11-26
categories:
- 文章资讯
- 技术教程
---
Nginx 高性能与稳态配置(worker、epoll、keepalive、sendfile 与缓存)
配置片段
worker_processes auto;
events { worker_connections 4096; use epoll; }
http {
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
types_hash_max_size 2048;
gzip on; gzip_types text/plain text/css application/javascript application/json;
open_file_cache max=1000 inactive=20s;
}
验证方法
- 压测观察并发连接、CPU 与带宽;对比优化前后吞吐与延迟。
- DevTools/
curl -I验证压缩与缓存头命中。 - 错误与访问日志分析热点与异常,调优连接与缓存参数。
注意事项
worker_connections与系统限制(ulimit -n)需匹配。- 压缩与缓存策略与上游/下游协同;避免重复或冲突。
- 在 HTTP/2/3 场景下验证兼容性与优先级策略。

发表评论 取消回复