How to Tune Nginx for Over 900k Requests per Second on Linux

This guide walks you through installing and configuring Nginx for extreme request rates, optimizing kernel TCP settings, and using Tsung to benchmark a server that can sustain more than 900,000 requests per second, with detailed command examples and configuration snippets.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Tune Nginx for Over 900k Requests per Second on Linux

Part 2: Using Nginx for High‑Performance Servers

This article is the second part of the series "Building a 3‑Million‑Requests‑Per‑Second High‑Performance Server Cluster". It demonstrates how to configure any web server, choosing Nginx for its lightweight, reliable, and high‑performance characteristics.

A well‑tuned Nginx on Linux can normally handle 500‑600k requests per second; the configuration shown here consistently reaches 904k requests per second and remains stable under a 12‑hour load test.

Installation and Basic Setup

Install Nginx from the EPEL repository: yum -y install nginx Backup the original configuration and edit it as needed:

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
vim /etc/nginx/nginx.conf

Key Nginx Performance Directives

Insert the following settings into nginx.conf (adjust values to match your hardware): worker_processes 24; worker_rlimit_nofile 200000; error_log /var/log/nginx/error.log crit; worker_connections 4000; use epoll; multi_accept on; open_file_cache max=200000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; access_log off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 30; keepalive_requests 100000; reset_timedout_connection on; client_body_timeout 10; send_timeout 2; gzip on; gzip_min_length 10240; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css text/xml application/javascript application/x-javascript; gzip_disable "MSIE [1-6].";

Start Nginx and enable it at boot:

service nginx start
chkconfig nginx on

Load Testing with Tsung

Configure Tsung (edit ~/.tsung/tsung.xml) to point to your web server and start the test: tsung start After the test finishes (about 10 minutes for a peak measurement), press Ctrl+C and view the report with the previously defined alias treport.

Web Server Tuning – Part 2: TCP Stack Optimization

The following kernel TCP settings improve network bandwidth for any web server. On a 10‑Gbps NIC they raised throughput from 8 Gbps to 9.3 Gbps.

Install Benchmark Tools

yum -y install netperf iperf

Modify sysctl Parameters

Edit /etc/sysctl.conf and add:

# Increase local port range
net.ipv4.ip_local_port_range = 2000 65000
# Enable TCP window scaling
net.ipv4.tcp_window_scaling = 1
# Increase SYN backlog
net.ipv4.tcp_max_syn_backlog = 3240000
# Increase listen backlog
net.core.somaxconn = 3240000
# Increase TIME_WAIT buckets
net.ipv4.tcp_max_tw_buckets = 1440000
# Increase socket buffers
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# Use cubic congestion control
net.ipv4.tcp_congestion_control = cubic

Apply the changes: sysctl -p /etc/sysctl.conf After each change, run a network benchmark (netperf, iperf, or a custom script) to measure its impact.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Load TestingNginxHigh PerformanceSysctlTCP Tuning
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.