Systems Tuning
Tuning Nginx worker_processes, worker_connections & rlimit_nofile
Prevent "too many open files" and dropped Keep-Alive sockets across 20-40 CloudPanel vhosts by aligning sysctl fs.file-max, worker_rlimit_nofile, and epoll limits.
4,096 Conns/Worker · 65,535 rlimit_nofile · epoll + multi_accept
Why Default 1,024 Open-File Limits Break Multi-Site Proxies
Each Nginx site in CloudPanel acts as a reverse proxy to Varnish (:6081) or PHP-FPM sockets, doubling file descriptor consumption per connection. Raising worker_rlimit_nofile to 65535 prevents silent 502 socket exhaustion during traffic bursts.
Aligning Systemd Overrides
Setting worker_rlimit_nofile inside nginx.conf fails if the systemd service unit enforces a lower LimitNOFILE cap. Add a drop-in override in /etc/systemd/system/nginx.service.d/limits.conf.
Measured Parameters & CloudPanel Stack Directives
| Directive / Sysctl | Recommended Setting | Operational Reason |
|---|---|---|
| worker_processes | auto (1 per vCPU core) | Pins one event-loop process per vCPU without context-switch thrash |
| worker_connections | 4096 (8192 on 8-vCPU KVM 8) | Supports high concurrent HTTP/2 multiplexed browser and API streams |
| worker_rlimit_nofile | 65535 (and systemd LimitNOFILE) | Every proxied request consumes 2 FDs (client + Varnish/FPM upstream) |
| multi_accept / epoll | use epoll; multi_accept on; | Drains ready accept queue connections in one kernel wakeup |