Nginx vs Apache: Real-World Performance Comparison
We benchmark Nginx and Apache head-to-head for static files, PHP, concurrent connections, and memory usage. The results might surprise you.
Affiliate disclosure: We earn a commission when you sign up or buy through some of the links on this page, at no extra cost to you. It never affects our recommendations.
The 30-Second Version
Nginx is faster for static files and handles concurrent connections better. Apache is more flexible with .htaccess overrides and has broader module compatibility. For most hosting workloads in 2026, Nginx is the better default โ but Apache with event MPM and PHP-FPM is much closer than many people think.
The Architecture Difference
Apache uses a process-based or thread-based model. Each connection gets a thread (worker MPM) or a process (prefork MPM). This is simple to understand, but it means Apache's memory usage grows with connections. Under the traditional prefork MPM with mod_php, 100 concurrent connections = 100 Apache processes, each with PHP embedded = massive memory usage.
Modern Apache uses event MPM + PHP-FPM (FastCGI) to avoid this. Under event MPM, connection handling is asynchronous, and PHP runs in separate FPM pools. This brings Apache's concurrency model much closer to Nginx's.
Nginx is event-driven and asynchronous. A small number of worker processes handle thousands of connections using non-blocking I/O. Memory usage stays flat regardless of concurrent connections. PHP handling goes through FastCGI (PHP-FPM). This architecture is inherently more efficient for high concurrency.
Test Environment
- Server: Hetzner CX31 (2 vCPU, 4GB RAM, Debian 12)
- Apache: 2.4.61, event MPM, PHP 8.3-FPM
- Nginx: 1.26.1, PHP 8.3-FPM
- Testing tool: wrk2, constant throughput mode
- PHP workload: WordPress 6.6 (default theme, no plugins, no caching)
Benchmark Results
Static File Serving (1KB HTML file)
| Concurrency | Nginx req/s | Apache req/s | Nginx Advantage |
|---|
| 10 | 14,200 | 11,800 | +20% |
|---|---|---|---|
| 100 | 13,800 | 9,200 | +50% |
| 500 | 12,400 | 6,100 | +103% |
| 1,000 | 11,100 | 4,300 | +158% |
Nginx is consistently faster for static files, and the gap widens with concurrency. At 1,000 concurrent connections, Nginx serves 2.6x more requests per second.
WordPress (uncached, PHP dynamic page)
| Concurrency | Nginx req/s | Apache req/s | Nginx Advantage |
|---|
| 10 | 185 | 158 | +17% |
|---|---|---|---|
| 50 | 172 | 130 | +32% |
| 100 | 148 | 98 | +51% |
| 200 | 115 | 62 | +85% |
For PHP workloads, the gap is narrower at low concurrency but still significant under load. At 100 concurrent connections, Nginx serves 51% more requests.
Memory Usage (idle โ 100 concurrent connections)
| Server | Idle RAM | 100 Conn RAM | Growth |
|---|
| Nginx + PHP-FPM | 180 MB | 310 MB | +130 MB |
|---|---|---|---|
| Apache event + PHP-FPM | 220 MB | 390 MB | +170 MB |
| Apache prefork + mod_php | 310 MB | 780 MB | +470 MB |
Apache event MPM + PHP-FPM is comparable to Nginx in memory usage. The real memory hog is Apache prefork with mod_php โ nearly 2.5x the memory of Nginx under load.
Response Time at 99th Percentile (WordPress, 100 concurrent)
| Server | p50 | p95 | p99 |
|---|
| Nginx | 380ms | 890ms | 1,450ms |
|---|---|---|---|
| Apache event | 420ms | 1,020ms | 1,820ms |
| Apache prefork | 580ms | 1,540ms | 2,800ms |
Nginx delivers more consistent response times at high percentiles. The p99 difference (1,450ms vs 1,820ms) represents the experience of your slowest users.
When Apache Still Makes Sense
Despite the performance gap, Apache has legitimate use cases:
Shared hosting. Apache's .htaccess files allow per-directory configuration overrides without restarting the server. This is why virtually every shared host uses Apache โ each customer can have custom rewrite rules, redirects, and authentication without affecting others.
Legacy applications. Some applications rely on .htaccess for configuration (WordPress permalinks via mod_rewrite, for example). These work fine on Nginx with converted rules, but the conversion is extra work.
cPanel compatibility. cPanel requires Apache. It uses .htaccess for account-level configuration and mod_userdir for per-user web directories. If you need cPanel, you're using Apache.
Module ecosystem. Apache has been around since 1995 and has a vast module ecosystem. Some niche modules (mod_security for WAF, mod_qos for traffic shaping) have deeper Apache integration than their Nginx equivalents.
When Nginx Makes More Sense
High concurrency. If you expect more than 100 simultaneous connections, Nginx's event-driven architecture provides better performance at lower resource usage.
Reverse proxy. Nginx is an excellent reverse proxy and load balancer. The configuration syntax for proxying is clean and intuitive.
Static asset serving. For CDN-like use cases or serving large static files, Nginx's static file performance is significantly better.
Memory-constrained environments. VPS plans with 512MB-1GB RAM benefit from Nginx's lower memory footprint.
Modern stack deployments. Docker, Kubernetes, and microservice architectures overwhelmingly default to Nginx. Following that convention means better documentation and community support.
What About LiteSpeed?
LiteSpeed deserves mention as a third option. It's a drop-in Apache replacement (understands .htaccess, mod_rewrite rules, Apache config syntax) but uses an event-driven architecture similar to Nginx. In benchmarks, LiteSpeed is comparable to Nginx for static files, faster than both for PHP (due to its built-in LSCache and PHP handler), and maintains Apache compatibility.
The catch: LiteSpeed is commercial software. The free version (OpenLiteSpeed) exists but lacks .htaccess support and the full caching features of the paid versions. For WordPress on shared hosting, LiteSpeed is genuinely excellent โ but you'll pay for it either through hosting costs or a LiteSpeed license.
The Real-World Configuration
Here's what actually matters more than choosing Nginx or Apache:
PHP-FPM Configuration
; /etc/php/8.3/fpm/pool.d/www.conf
pm = dynamic
pm.max_children = 20
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 500
Misconfigured PHP-FPM is the most common cause of poor performance, regardless of web server choice. Too few children = queued requests. Too many = memory exhaustion.
Caching (the real performance lever)
A cached page served by either Nginx or Apache performs identically โ because the web server is just serving a static file at that point. The performance difference between Nginx and Apache only matters for uncached requests.
# Nginx fastcgi_cache example
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WP:100m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_valid 200 60m;
fastcgi_cache_use_stale error timeout invalid_header;
With proper caching, the Nginx vs Apache debate becomes largely academic for most sites. A cached WordPress site on either server will handle thousands of concurrent visitors without issue.
HTTP/2 and HTTP/3
Both Nginx and Apache support HTTP/2. Nginx added HTTP/3 support in 1.25.0; Apache has HTTP/3 through mod_http3. For modern web performance, HTTP/3 (QUIC) matters more than the Nginx vs Apache choice โ the protocol upgrade provides 15-30% faster page loads on high-latency connections.
Verdict
| Use Case | Recommendation |
|---|
| New project, no constraints | Nginx |
|---|---|
| Shared hosting / cPanel | Apache |
| WordPress on shared hosting | LiteSpeed (if available) or Apache event MPM |
| High-traffic site (>100 concurrent) | Nginx |
| Reverse proxy / load balancer | Nginx |
| Legacy .htaccess-dependent app | Apache |
| API backend | Nginx |
| Low-memory VPS (512MB) | Nginx |
| Want to use .htaccess | Apache or LiteSpeed |
The honest answer for 2026: Nginx is the better default. It's faster under concurrency, uses less memory, has better documentation for modern deployments, and is the standard in containerised environments. But Apache with event MPM + PHP-FPM is close enough that you shouldn't migrate an existing Apache setup to Nginx purely for performance โ the gains are modest compared to adding proper caching.
If you're starting fresh, go with Nginx. If you're on Apache and curious about switching, benchmark your specific workload before committing to a migration. For most sites, caching matters more than the web server choice.
Related Comparisons
- [Cloud Hosting vs Traditional VPS](/comparisons/cloud-hosting-vs-traditional-vps) โ Infrastructure choice affects web server decisions
- [What Is a Reverse Proxy?](/guides/what-is-a-reverse-proxy) โ How Nginx functions as a reverse proxy
- [TTFB and Server Response Times](/guides/ttfb-server-response-times) โ Web server impact on performance
Want neither? Let OpsHelp handle everything.
Managed hosting with support, security, backups, and monitoring โ from ยฃ50/mo. We handle the servers, you focus on your business.