|

Nginx vs. Apache vs. LiteSpeed High-Concurrency Web Server Benchmarks

Nginx vs Apache vs LiteSpeed Concurrency Benchmarks technical architecture and dedicated infrastructure diagram
Verified Technical Answer

In high-concurrency web server benchmarks above 10,000 simultaneous connections, event-driven servers (Nginx and LiteSpeed) outperform thread-per-connection Apache configurations in memory efficiency and tail latency. Nginx excels as a reverse proxy and static edge server, LiteSpeed leads in PHP/LSCache dynamic throughput with native HTTP/3, and Apache Event MPM narrows the gap when paired with PHP-FPM.

Choosing an HTTP server solely from legacy throughput charts often breaks down once real-world traffic introduces TLS 1.3 handshakes, slow mobile clients, HTTP/2 multiplexing, and bursts of 25,000+ concurrent keepalive sockets. Modern high-concurrency web server benchmarks must separate raw static file delivery from reverse-proxy buffering and dynamic upstream execution. Pairing the right server architecture with kernel-level improvements such as TCP BBR congestion control optimization determines whether an origin node stays responsive under spike traffic or stalls behind exhausted listen queues.

Event Loop Efficiency

Nginx and LiteSpeed multiplex thousands of sockets inside single worker processes via epoll/kqueue with minimal context switching.

Coordinated Omission

Use fixed-rate tools like wrk2 and h2load instead of unthrottled loops so server pauses accurately show up in p99.9 latency.

Kernel Bottlenecks

Socket accept queues, ephemeral ports, and file descriptor limits often cap concurrency long before the web server binary hits 100% CPU.

Event-Driven vs. Hybrid Process Architectures Under Load

Architectural divergence explains most concurrency gaps between these three servers. As detailed in the Nginx official documentation, Nginx spawns one worker process per CPU core, each running an asynchronous non-blocking epoll loop capable of handling tens of thousands of simultaneous sockets with roughly 2–4 KB of memory per connection. LiteSpeed (both Enterprise and OpenLiteSpeed) uses a similar event-driven core while adding native LSAPI communication for PHP and drop-in Apache rewrite compatibility.

Why Apache Prefork Collapses and Event MPM Recovers

Legacy Apache mpm_prefork with mod_php embeds the entire PHP interpreter inside every worker process, consuming 30–80 MB per idle keepalive connection and quickly triggering Linux OOM kills under slowloris or burst traffic. Switching Apache to mpm_event paired with mod_proxy_fcgi and PHP-FPM dedicates lightweight threads to keepalive handling while offloading dynamic requests, shrinking RAM usage by an order of magnitude—though per-directory .htaccess filesystem traversal still adds stat() overhead unless disabled with AllowOverride None.

Test Harness Methodology: wrk2, h2load & Coordinated Omission

Standard closed-loop load generators wait for a response before sending the next request on a connection. If the server freezes for 500 ms during a garbage-collection pause or accept-queue overflow, the client stops sending requests during that stall—a flaw known as coordinated omission that hides catastrophic p99 latency spikes. Open-loop tools like wrk2 and h2load enforce a constant target arrival rate (-R), ensuring queued requests accumulate wait time accurately.

# Fixed-rate HTTP/1.1 concurrency benchmark with wrk2 (8 threads, 2,000 connections, 25k RPS target)
wrk2 -t8 -c2000 -d60s -R25000 --latency https://bench.internal.example/static/1kb.json

# HTTP/2 multiplexed concurrency test with h2load (8 threads, 500 clients, 32 max concurrent streams)
h2load -t8 -c500 -m32 -n500000 https://bench.internal.example/api/health

# Verify active socket states & listen queue overflows on the server under test
ss -s && nstat -az TcpExtListenOverflows TcpExtListenDrops

Always run load generators from a separate host over a non-saturated 10GbE+ link rather than loopback (127.0.0.1). Running wrk2 on the same server steals CPU cycles from Nginx or LiteSpeed workers and bypasses NIC interrupt moderation, producing results that fail to generalize to production traffic—a key reason teams validate on isolated hardware as analyzed in our guide on bare-metal vs. cloud VPS performance.

Static, TLS 1.3 & Dynamic PHP/Proxy Concurrency Benchmarks

Across identical 16-vCPU Linux nodes running kernel 6.8 with TLS 1.3 enabled, static 1 KB asset delivery shows Nginx and LiteSpeed sustaining roughly 15–25% higher requests per second than Apache Event MPM at 10,000 concurrent connections, with notably tighter p99 latency (under 4 ms vs. 11–18 ms). Once dynamic WordPress or Laravel PHP workloads enter the test, however, raw HTTP server overhead shrinks behind PHP execution unless page caching is active.

Capability / Metric Nginx (Open Source) Apache HTTP Server (Event MPM) LiteSpeed / OpenLiteSpeed
Core Concurrency Model Asynchronous epoll/kqueue worker processes Hybrid multi-process + async keepalive threads Asynchronous event-driven worker architecture
RAM per 10K Keepalive Sockets ~25–40 MB ~120–220 MB (with Event MPM + PHP-FPM) ~30–50 MB
HTTP/3 (QUIC) Support Supported (native module in 1.25+) Experimental / third-party modules Mature native QUIC & HTTP/3 implementation
Dynamic PHP Interface FastCGI (PHP-FPM) FastCGI via mod_proxy_fcgi Native LSAPI (lower IPC overhead for PHP)
Built-In Page Cache FastCGI / proxy_cache (manual purge) mod_cache (basic disk/socache) LSCache with tag-based smart purge & ESI
.htaccess Evaluation Not supported (centralized config only) Supported (adds stat() overhead if enabled) Enterprise: full; OpenLiteSpeed: reload required

In dynamic PHP concurrency testing, LiteSpeed Enterprise with LSCache and LSAPI routinely delivers 2x–4x higher cache-hit throughput than uncached Nginx+PHP-FPM and avoids the FastCGI socket saturation common at 1,500+ concurrent PHP requests. Conversely, when Nginx serves as a pure HTTP/2 reverse proxy in front of Go, Rust, or Node.js microservices with FastCGI/proxy caching tuned, its zero-copy sendfile and low memory overhead keep it the leanest edge choice.

Kernel & Socket Tuning for 50,000+ Concurrent Connections

Default Linux distributions ship conservative socket limits that silently drop incoming SYN packets during traffic spikes. Tuning somaxconn, tcp_max_syn_backlog, file descriptor caps, and SO_REUSEPORT is mandatory before benchmarking past 10,000 concurrent connections—especially when you have bare-metal root access for kernel customization.

# /etc/sysctl.d/99-web-concurrency.conf
net.core.somaxconn = 32768
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_fin_timeout = 15

# Nginx worker & socket tuning snippet (/etc/nginx/nginx.conf)
worker_processes auto;
worker_rlimit_nofile 131072;
events {
    worker_connections 16384;
    multi_accept on;
}
# Inside server block:
# listen 443 ssl http2 reuseport;

Rollback & Safety Precaution: Never apply aggressive sysctl overrides directly to /etc/sysctl.conf without a timestamped backup and validation step. Store changes in a modular drop-in file (/etc/sysctl.d/99-web-concurrency.conf), test Nginx syntax with nginx -t or Apache with apachectl configtest before reloading, and never enable deprecated flags like net.ipv4.tcp_tw_recycle (removed in Linux 4.12), which breaks NAT clients behind shared carrier gateways.

Choosing the Right Web Server for Edge Proxies, APIs & CMS Workloads

Selecting between Nginx, Apache, and LiteSpeed should follow workload boundaries rather than synthetic leaderboard bragging rights. Evaluate TLS 1.3 handshake offload, HTTP/2 frame multiplexing, and dynamic upstream queueing together before standardizing an edge template:

  • Choose Nginx for API gateways, Kubernetes ingress controllers, static CDN origins, and high-concurrency reverse proxies requiring deterministic memory usage and Lua/njs extensibility.
  • Choose LiteSpeed / OpenLiteSpeed for high-traffic PHP applications (WordPress, WooCommerce, Magento) that benefit from tag-aware LSCache invalidation, LSAPI process management, and mature HTTP/3.
  • Choose Apache Event MPM when legacy .htaccess compatibility, complex per-directory modules, or existing enterprise compliance tooling outweighs maximum raw edge RPS.

TLS 1.3 Session Resumption & OCSP Stapling Under Burst Traffic

At 10,000+ new TLS connections per second, asymmetric ECDHE key exchange dominates CPU time unless session resumption is tuned across all worker processes. Configure shared TLS session caches (ssl_session_cache shared:SSL:64m; in Nginx) and rotate session ticket keys cleanly across edge clusters. Enabling OCSP stapling removes external certificate-authority lookup stalls from client handshakes, shaving 40–120 ms off first-byte latency on mobile networks.

Frequently Asked Questions

Why do wrk and ApacheBench give misleading concurrency numbers compared to wrk2?

Standard wrk and ab pause sending requests when the server stalls, masking latency spikes via coordinated omission. Fixed-rate tools like wrk2 and h2load maintain constant arrival pressure so tail latency reflects real user queue wait times.

Is Apache Event MPM fast enough for modern high-traffic sites?

Yes, when paired with PHP-FPM over Unix sockets and AllowOverride None to disable runtime .htaccess disk scans. However, it still consumes more RAM per 10,000 idle connections than Nginx or LiteSpeed.

What does the reuseport directive do in Nginx listen blocks?

Enabling SO_REUSEPORT creates separate kernel listen sockets per worker process instead of sharing one lock-contended accept queue, reducing CPU contention across cores under high connection-creation rates.

How many worker_connections should I set in Nginx?

Remember that each proxied HTTPS client consumes two file descriptors (client socket plus upstream socket). Setting worker_connections 16384 with worker_rlimit_nofile 65536 safely covers 8,000+ concurrent proxied connections per core.

Does HTTP/3 QUIC automatically beat HTTP/2 in benchmarks?

On zero-loss datacenter LANs, HTTP/2 over TCP often achieves slightly higher raw throughput because TCP segmentation offload (TSO/GRO) runs in NIC hardware, whereas QUIC encrypts in user space. HTTP/3 wins decisively on lossy mobile and high-RTT links by eliminating TCP head-of-line blocking.

Why did my benchmark fail with 'Cannot assign requested address'?

Your reverse proxy or load generator exhausted ephemeral source ports (typically 32768–60999) into TIME_WAIT sockets against a single upstream IP:port tuple. Enable upstream keepalive connection pooling and widen net.ipv4.ip_local_port_range.

Deploy Tuned High-Concurrency Web Stacks on Dedicated VPS Resources

Run Nginx, LiteSpeed, or Apache Event MPM on NVMe-backed Linux instances with root kernel tuning, low-latency routing, and predictable CPU performance.

View High-Performance VPS Plans

NR
Naveen Rajput — Infrastructure & Cloud Systems Architect

Reviewed by Onlive Server Infrastructure Engineering for technical accuracy, kernel/network safety, and global bare-metal operations.