Apache HTTP Server Performance Optimization

Apache HTTP Server Performance Optimization

Apache HTTP Server powers a significant portion of the world's websites, but its default configuration is far from optimal for high-traffic environments. Careful tuning of modules, multi-processing modules (MPMs), and resource limits can dramatically increase throughput and reduce response times.

Choosing the Right MPM

Apache offers multiple MPMs: prefork uses separate processes per connection and is required for non-thread-safe modules like mod_php. Worker uses threads within processes for better memory efficiency. For modern deployments, the event MPM provides the best performance by using a dedicated listener thread to handle keep-alive connections, freeing worker threads for active requests.

Disable any modules you are not using. Each loaded module consumes memory and adds processing overhead to every request. Common modules that can often be removed include mod_autoindex, mod_status (in production), and mod_cgi if you use FastCGI exclusively. Use apachectl -M to list currently loaded modules.

Configure appropriate MaxRequestWorkers (formerly MaxClients) based on available memory divided by the average memory per Apache process. Setting this too high causes swapping, which destroys performance. Enable mod_deflate for text-based content types and set appropriate Expires headers to leverage browser caching and reduce server load.

Back to Blog