Apache · Configuration and operations

How do you approach Apache performance tuning?

HardperformancetuningcapacityUpdated Oct 2026
Quiz this track

Short answer

Measure before changing anything, then tune the MPM, keep-alive, caching and compression against the real workload. The biggest wins often come from removing per-request overhead and moving work to the right layer.

Performance work starts with a baseline: requests per second, latency percentiles, error rate, CPU, memory and the mod_status scoreboard. Without that, MPM changes are guesswork. A server that is CPU-bound needs different changes from one that is waiting on a backend or running out of workers.

apache
ExtendedStatus On
<Location "/server-status">
  SetHandler server-status
  Require ip 127.0.0.1
</Location>

KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 5

<IfModule mpm_event_module>
  ServerLimit 16
  ThreadsPerChild 25
  MaxRequestWorkers 400
  MaxConnectionsPerChild 0
</IfModule>

Where the wins usually are

  • Serve static assets from a CDN or a dedicated edge instead of the application host
  • Set far-future cache headers on versioned assets and enable compression
  • Disable .htaccess and move rules into virtual host configuration
  • Fix slow backends before increasing worker counts; more workers can amplify overload
  • Tune keep-alive to match the load balancer and client behaviour
  • Avoid expensive modules or per-request DNS lookups in hot paths
  • Use HTTP/2 and TLS session resumption for connection-heavy workloads
  • Watch file descriptor and memory limits; workers cannot exceed them

Sizing is a memory equation. Estimate the footprint per process or thread, multiply by the configured concurrency, and leave headroom for the OS, page cache and other services. Increasing MaxRequestWorkers without memory headroom causes swapping, which is worse than queueing.

A benchmark against a local static file does not predict performance for a TLS-terminating, proxying, PHP-backed site. Load-test the real path with realistic payloads and concurrency.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What metrics do you collect before tuning?
  2. 2Why can adding workers make an overloaded system worse?
  3. 3How do you size MaxRequestWorkers from memory?
  4. 4Which Apache features would you disable on a static asset host?

Say it in the interview

I baseline latency, throughput, errors, CPU, memory and the scoreboard before touching config. Then I fix the actual bottleneck: static assets to a CDN, caching and compression, .htaccess disabled, keep-alive tuned. I size workers from memory headroom, not just traffic. More workers on an overloaded backend usually makes things worse.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Apache mock interview and get scored feedback on depth, clarity and confidence.