Stockio

Nginx vs Apache Performance on Shared Hosting

Benchmark Nginx and Apache fairly on shared hosting with matched workloads, repeatable timing checks, controlled load tests, and bottleneck diagnosis.

By Ethan Clarke

Performance & SEO Specialist ·

On this page

Choosing between Nginx and Apache based on a single requests-per-second chart often solves the wrong problem. On shared hosting, PHP limits, database contention, cache policy, and account quotas can dominate the web server choice.

A useful comparison measures the same workload under documented conditions. This guide creates a repeatable test plan, distinguishes cached traffic from application work, and turns results into questions your hosting provider can actually answer.

Define the question before measuring speed

Separate response latency from capacity under load. A fast request from one location tells you little about how a blog behaves when many readers arrive together. Likewise, a high throughput result is meaningless if errors or stale content account for the extra responses.

Use the API Latency Tester below for an initial comparison of reachable endpoints. Compare equivalent URLs and record the tool's reported timing and status. Treat it as a lightweight observation point, not a controlled concurrency generator or proof of global visitor experience.

Choose a representative workload: a static asset, a cacheable article, and an uncached application route that you own. Do not benchmark login attempts or actions that send mail. On shared infrastructure, obtain permission for load testing and respect the host's acceptable-use policy and rate limits.

Define success before testing. For example, require no unexpected errors, stable tail latency, and adequate headroom at your expected arrival rate. Avoid inventing a universal winning server; the useful outcome is whether each configuration meets your site's service target.

Make the environments genuinely comparable

Document resource limits for both environments: CPU entitlement, RAM, I/O throttling, PHP worker allowance, database placement, and concurrent connection caps. A host describing its stack as Nginx may still forward dynamic requests to Apache, so ask which component actually executes PHP.

Check software versions and cache layers. Use the same PHP build, extensions, application revision, database snapshot, compression policy, TLS configuration, and content. Warm caches consistently or explicitly test cold behavior separately. Never combine those observations into one supposedly definitive average.

The Nginx documentation describes its event-driven request handling and FastCGI integration. The Apache documentation explains multiple processing modules; Apache with the event MPM and PHP-FPM is not equivalent to prefork with embedded PHP.

Keep CDN involvement explicit. Either compare through the same CDN configuration or test authorized origins directly with the correct hostname and certificate verification. Requests served by an edge cache mostly measure that edge, not the origin server you are trying to compare.

Write down the test client's location and network path. If one origin is much farther away, transport latency can hide differences in processing time. Record that constraint rather than presenting regional differences as a web-server architecture result.

Collect a single-request baseline

Start with repeatable timing and response verification. Inspect cache headers, content length, status, and redirects before adding concurrency. A cached error page can be impressively fast while delivering nothing useful.

curl -sS -o /dev/null   -w 'status=%{http_code} dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} first_byte=%{time_starttransfer} total=%{time_total}
'   https://example.com/benchmark-article/
curl -sS -D /tmp/blog-headers.txt   -o /tmp/blog-body.txt https://example.com/benchmark-article/

Curl's timing fields are cumulative milestones, not independent durations. Subtract connection time from TLS completion when investigating the handshake phase. Time to first byte includes earlier network work, so it is not a direct measurement of PHP execution time.

Run several repetitions and retain individual observations. Record redirects separately rather than hiding them behind automatic following. Check the downloaded body for an expected title or marker, and ensure both environments return equivalent content and cache policy.

Use the latency testing tool again after changes for a quick consistency check. For full browser rendering, add browser measurements separately: HTML response speed does not include image decoding, JavaScript execution, or layout stability.

Increase load gradually and preserve evidence

Use a staging clone or a provider-approved test window. Begin with low concurrency, wait for stable behavior, then increase one variable at a time. ApacheBench is widely available, though its connection model is not a complete simulation of modern HTTP/2 browsers.

ab -n 100 -c 2 -k https://example.com/benchmark-article/
ab -n 300 -c 5 -k https://example.com/benchmark-article/
ab -n 100 -c 2 -k https://example.com/wp-json/

These are deliberately small starting runs, not recommended production traffic levels. Confirm that the selected endpoint exists and that your provider permits even these requests. ApacheBench reports failed requests and percentile timings; inspect them alongside server logs rather than quoting requests per second alone.

Capture tail latency, non-success statuses, and actual response sizes. Stop immediately when errors rise, resource alarms fire, or other tenants might be affected. Repeatedly pushing past a known limit provides little additional information and can breach hosting terms.

Repeat each condition in multiple rounds, alternating environment order. A shared server's noisy neighbors can change results during the same afternoon. Retain raw output and configuration notes so a later retest can distinguish a genuine improvement from ordinary variability.

Explain the bottleneck before choosing a stack

A static-file advantage does not automatically improve uncached PHP throughput. If every dynamic request waits for a database lock, changing the front-end server may leave the limiting resource untouched. Check PHP queues, slow queries, disk latency, and upstream errors together.

For accounts without system access, request provider metrics around the exact test window. Ask whether throttling, worker limits, or account-level entry-process limits were reached. An unexplained plateau is not evidence that a server product cannot scale.

If you administer the server, correlate access and error logs with resource observations. This example reads status only; available tools and service names vary by distribution.

uptime
free -m
vmstat 1 10
sudo journalctl -u nginx --since '15 minutes ago' --no-pager
sudo journalctl -u apache2 --since '15 minutes ago' --no-pager

Consult web.dev for the distinction between server responsiveness and user-facing performance. Faster HTML delivery matters, but heavy assets or render-blocking scripts may still dominate the page experience.

When queues point at PHP, continue with the PHP-FPM worker guide. Avoid increasing concurrency blindly: extra workers consume memory and can overload the database sooner.

For choosing hosting, summarize observed behavior rather than declaring a winner. A useful report lists workload, cache state, authorized load level, errors, latency distribution, and resource limits. Then evaluate operational requirements such as rewrite compatibility, support access, configuration control, and migration effort.

A site dependent on per-directory rewrite rules may value Apache compatibility more than a small static-file difference. A mostly cached publication may benefit more from correct cache invalidation than either server's synthetic benchmark score.

Key takeaways

  • Compare equivalent workloads with identical application state, caching, and documented resource limits.
  • Use single-request timing as a baseline, then test authorized concurrency separately.
  • Track errors and tail latency, not only headline throughput or averages.
  • Diagnose PHP, database, and account quotas before attributing slowdowns to Nginx or Apache.
  • Choose the stack that meets measured requirements and operational constraints, not a universal benchmark ranking.
Featured sponsor

Reach designers & developers at work

Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.

Become a sponsor

Keep reading

Related articles

More in Web Hosting & Servers
Web Hosting & Servers

Nginx Reverse Proxy Cache vs Varnish for Dynamic Sites

Configure a conservative Nginx reverse proxy cache, protect private responses, and verify cache hits, freshness, and origin latency before expanding coverage.

Includes: API latencyRavi DesaiRavi Desai
Web Hosting & Servers

Website Speed Audit Checklist Before Switching Hosts

Audit browser loading, connection timing, and server pressure with repeatable tests to identify the actual bottleneck before paying to change hosting providers.

Includes: API latencyRavi DesaiRavi Desai
Web Hosting & Servers

Redis Object Cache for WooCommerce on Managed Hosting

Enable Redis object caching for WooCommerce safely, verify persistent cache hits, measure uncached request latency, and protect checkout from stale data.

Includes: API latencyRavi DesaiRavi Desai
DevOps & Deployment

10 Best Uptime Monitoring Tools

Compare ten uptime monitoring services for websites and APIs, from simple availability checks to incident workflows. Learn what each is suited to, what it cannot tell you, and how to choose.

Includes: API latencyRavi DesaiRavi Desai
Backend & APIs

12 Best Free Public APIs for Side Projects

Find approachable public APIs for weather, books, countries, and sample data, plus practical notes on access, limits, and choosing an endpoint for a side project.

Includes: API latencyChidi NwosuChidi Nwosu
AI Builders & APIs

10 Best AI APIs for Developers

Compare ten established AI APIs for chat, search, and production applications, with notes on their strengths, trade-offs, pricing models, and what to check before choosing a provider.

Includes: API latencyDaniel KimDaniel Kim