Web / NGINX Interview questions
How can you optimize NGINX for high-traffic websites?
Several tuning levers matter most once traffic climbs into high-concurrency territory.
- Worker tuning - set
worker_processes auto;to match CPU core count, and raiseworker_connectionsso each worker can hold more simultaneous connections. - Keepalive to upstreams - configure a
keepaliveconnection pool in theupstreamblock so NGINX reuses TCP connections to backends instead of opening a new one per request. - Caching - use
proxy_cachefor responses that don't change on every request, cutting backend load substantially. - Static asset offloading - serve static files directly from disk via
rootrather than proxying them through the application layer. - Compression - enable Gzip or Brotli for text-based responses to reduce bytes on the wire.
- Buffer tuning - size
proxy_buffersand related directives to match typical response sizes, avoiding excessive disk spooling for large responses.
Beyond configuration, high-traffic setups usually pair NGINX with monitoring - tracking active connections, request latency, and upstream response times - so tuning decisions are based on real bottlenecks rather than guesswork.
More Related questions...