Which MPM best serves mixed static/dynamic workloads in Apache 2.4?
0 reputation · 20 Sept 2022, 02:49 UTC
0 reputation · 20 Sept 2022, 02:49 UTC
Determine which MPM module—mpm_event or mpm_worker—provides the best performance for a server that serves both static assets and dynamic content, after measuring the current bottleneck with Apache’s built‑in diagnostics.
mod_deflate enabled for compression.Official documentation does not recommend one MPM over the other for mixed workloads; the optimal choice depends on measured CPU, memory, and latency characteristics.
mod_status with ExtendedStatus On to separate CPU usage caused by mod_deflate from that caused by request handling?mpm_event or mpm_worker—yields lower average latency when the server is under bursty traffic, given the current KeepAliveTimeout?32775 reputation · 20 Sept 2022, 04:31 UTC
For a server serving mixed static and dynamic content under Apache 2.4—especially with a high KeepAliveTimeout—mpm_event is the superior choice over mpm_worker.
The primary reason is management of idle connections. mpm_worker assigns a dedicated worker thread to the entire duration of a Keep-Alive session. If your timeout is set to 5 seconds, those threads remain tied up by clients not actively sending data, leading to thread pool exhaustion during traffic bursts. In contrast, mpm_event uses a dedicated listener thread to monitor Keep-Alive connections, only assigning a worker thread when there is an actual request to process.
While both MPMs use a multi-threaded architecture, their handling of concurrency differs in ways that impact your specific constraints:
mpm_event frees up worker threads during the I/O wait times of Keep-Alive sessions. This allows the server to handle more concurrent static requests without hitting the thread limit.mpm_event maintains lower average latency because dynamic requests are less likely to be queued waiting for a thread held by an idle static session.mpm_event typically consumes less resident set size (RSS) as connection counts scale.To confirm this behavior on your specific hardware, follow this diagnostic path:
mod_status is enabled and set ExtendedStatus On in your Apache configuration.wrk or ab (Apache Benchmark) to simulate bursty traffic with long-lived connections. For example: ab -n 10000 -c 500 -k http://your-server/(the
-k flag enables Keep-Alive).
server-status page. Look at the "Busy" vs. "Idle" thread counts. In mpm_worker, you will likely see Busy threads hit your MaxRequestWorkers limit quickly. In mpm_event, Busy threads should remain proportional to active requests only.top or htop to monitor the RSS of the Apache child processes during the load test to compare between the two modules.Note: While mod_deflate increases CPU usage on both MPMs, mpm_event mitigates the impact on throughput by ensuring CPU cycles aren't wasted on managing blocked threads.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.