Nginx 性能调优的方法有很多,主要包括以下几点:
减少 worker_processes 的数量:默认为 CPU 核数,可根据实际情况减少。
增加 worker_connections 的值:默认为 1024,可根据实际情况增加。
使用 sendfile on 或 offload:sendfile on 表示允许 Nginx 使用 sendfile 系统调用,offload 则表示使用硬件加速。
配置缓存:使用 proxy_cache 或 fastcgi_cache 可以缓存静态文件,提高访问速度。
合理配置 keepalive_timeout:设置