Performance Tuning
Recommended Multi-Core Baseline
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 65535;
events {
worker_connections 16384;
}
http {
sendfile on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 10000;
brotli_static on;
server {
listen 80 reuseport;
listen 443 ssl reuseport;
listen 443 quic reuseport;
http2 on;
http3 on;
...
}
}Key Tuning Levers
reuseport+worker_cpu_affinity auto;: Eliminates accept-queue contention across cores on multi-core Linux hosts by giving each worker its own kernel listen queue pinned to a CPU core.- Native
io_uring& UDP GSO: naati automatically enables Linuxio_uring(falling back toepollwhere restricted) andUDP_SEGMENT(UDP GSO) for HTTP/3 without extra config directives. - Precompressed static assets: Pair
brotli_static on;andgzip_static on;with pre-compressed.br/.gzassets to avoid per-request compression CPU overhead. - Upstream
keepalive: Always pairkeepalive 64;withproxy_http_version 1.1; proxy_set_header Connection "";to eliminate per-request TCP handshake overhead to backends. - Container CPU limits: In Docker or Kubernetes with CPU quotas, set
NAATI_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=1so worker count matches the cgroup quota rather than host physical cores. - Linux kernel sysctls for high connection counts:
sudo sysctl -w \
net.core.somaxconn=65535 \
net.ipv4.tcp_max_syn_backlog=65535 \
net.ipv4.ip_local_port_range="1024 65535" \
net.core.netdev_max_backlog=16384