Apache MaxRequestWorkers Calculator
Estimate a safe Apache concurrency limit based on available RAM, reserved system memory, Apache worker size, MPM mode, and a protective safety buffer. This calculator helps you avoid swap pressure, protect latency, and set a practical MaxRequestWorkers value for production servers.
Calculator
Expert Guide: How to Size Apache MaxRequestWorkers Correctly
The MaxRequestWorkers directive is one of the most important Apache settings for performance engineering. It controls the maximum number of simultaneous requests Apache can actively serve. If the number is too low, legitimate traffic queues up and users see slower response times under load. If the number is too high, your server can exhaust RAM, start swapping, and collapse overall throughput. A good Apache MaxRequestWorkers calculator solves this problem by turning memory capacity into a practical concurrency ceiling.
At its core, the logic is simple: Apache workers consume memory, your system has finite RAM, and you must leave enough headroom for the operating system and other services. In real production environments, however, several factors complicate the calculation. The chosen Multi-Processing Module, your PHP architecture, traffic shape, keep-alive behavior, TLS overhead, reverse proxy layers, and the average size of application requests all influence how much memory is consumed at peak concurrency. That is why the best approach is not to rely on a hardcoded rule of thumb, but to use measured values from your own server.
What MaxRequestWorkers Actually Does
MaxRequestWorkers defines the upper bound on active request-handling slots inside Apache. Once that ceiling is reached, additional clients must wait until an existing worker finishes. The directive therefore acts as both a safety mechanism and a throughput limiter. In prefork mode, each worker is a separate process. In worker and event modes, the concurrency model is based on threaded children, so the total request capacity depends on both child processes and threads per child.
This directive has direct consequences for:
- Latency under load: too few workers increases queueing.
- Memory stability: too many workers risks swapping and OOM kills.
- CPU efficiency: over-allocation may create context switching without improving throughput.
- User experience: timeouts and erratic performance become more likely when concurrency exceeds memory limits.
The Core Formula Behind an Apache MaxRequestWorkers Calculator
The standard memory-based formula is:
MaxRequestWorkers = floor((Available RAM for Apache) / (Average memory per worker))
To make the formula production-safe, advanced sizing adds two more adjustments:
- Reserved memory for the operating system, logging, databases, PHP-FPM, caches, monitoring, and background jobs.
- Safety buffer to account for spikes, request variability, and periodic workload surges.
That produces a more realistic planning equation:
Recommended MaxRequestWorkers = floor(((Total RAM – Reserved RAM) × (1 – Buffer%)) / Effective worker memory)
The “effective worker memory” should be based on measured usage, not idealized documentation. If your application mixes static assets, dynamic PHP pages, API calls, TLS sessions, and compression, worker memory can vary significantly during a traffic spike. For that reason, this calculator also includes a headroom multiplier that inflates the worker estimate to reflect operational risk.
Why the Apache MPM Matters
Apache supports several MPMs, but most modern deployments use prefork, worker, or event. The right MaxRequestWorkers value must align with the MPM because each one uses memory differently. Prefork is process-heavy and generally consumes the most RAM per active request. Worker and event are more efficient because they use threads, and event is specifically designed to handle keep-alive connections more efficiently.
| MPM | Concurrency Model | Typical Memory Pattern | Operational Notes | Common Default MaxRequestWorkers |
|---|---|---|---|---|
| Prefork | One process per request | Often 30 MB to 100+ MB per process on dynamic stacks | Simple isolation, but highest memory usage; historically used with mod_php | 256 |
| Worker | Processes with multiple threads | Lower memory per concurrent request than prefork | Good balance of performance and compatibility for many threaded workloads | 400 with typical 16 ServerLimit and 25 ThreadsPerChild |
| Event | Threaded with improved keep-alive handling | Usually most efficient under many idle keep-alive connections | Common recommendation for modern Apache with PHP-FPM or reverse proxy use | 400 with typical 16 ServerLimit and 25 ThreadsPerChild |
These default values should not be treated as universal recommendations. They are simply software defaults. On a small virtual machine, 400 concurrent workers can be dangerously high if each worker uses substantial memory. On a larger system, 400 may be unnecessarily conservative. The correct setting is always server-specific.
How to Measure Memory Per Apache Worker
The most common sizing mistake is guessing worker memory. Real-world Apache usage depends on modules, rewrite rules, compression, TLS, proxied upstreams, application code, and request payloads. The best method is to observe the server under representative production load. Use process-level metrics from tools such as ps, top, htop, and Apache server-status. If you run PHP-FPM, be careful not to mix Apache memory with PHP-FPM pool memory. The more accurate your measurement, the more useful your calculator result becomes.
Useful measurement practices
- Sample memory during normal load and during peak traffic windows.
- Measure active workers only, not just idle baseline processes.
- Account for TLS, compression, and large responses if they are common.
- Review logs for burst patterns caused by bots, cron jobs, or campaigns.
Common sources of underestimation
- Ignoring PHP-FPM or backend service memory.
- Using static file tests instead of dynamic application traffic.
- Measuring on an idle node instead of a loaded one.
- Failing to reserve RAM for the kernel page cache and system daemons.
Worked Example
Suppose you have a server with 16 GB of RAM. You reserve 4 GB for the operating system, PHP-FPM, Redis, backups, and monitoring. That leaves 12 GB, or 12,288 MB, potentially available to Apache. You apply a 15% safety buffer, which reduces usable Apache RAM to about 10,445 MB. If your measured average memory per worker is 60 MB and you choose a 1.1 peak headroom multiplier, your effective worker memory becomes 66 MB. The resulting recommendation is:
floor(10,445 / 66) = 158
If you use event MPM with 25 ThreadsPerChild, Apache works best when MaxRequestWorkers is a multiple of 25. So the calculator rounds down to 150. That leads to a matching ServerLimit of 6 because 6 children × 25 threads = 150 request slots.
This is exactly why an MPM-aware calculator is useful. Without thread alignment, administrators may choose values that look mathematically correct but do not map cleanly to Apache’s process model.
Comparison Table: Example Server Sizes and Recommended Outcomes
| Server RAM | Reserved RAM | Buffer | Effective Worker Memory | Raw Max Workers | Practical Recommendation |
|---|---|---|---|---|---|
| 4 GB | 1.5 GB | 15% | 50 MB | 43 | Prefork: 43, Worker/Event with 25 threads: 25 |
| 8 GB | 2.5 GB | 15% | 55 MB | 87 | Prefork: 87, Worker/Event with 25 threads: 75 |
| 16 GB | 4 GB | 15% | 66 MB | 158 | Prefork: 158, Worker/Event with 25 threads: 150 |
| 32 GB | 8 GB | 20% | 70 MB | 280 | Prefork: 280, Worker/Event with 25 threads: 275 |
Notice how thread-based MPMs often round down. That is intentional. Apache’s capacity planning should favor stable divisibility over squeezing in one extra partial block of threads.
How MaxRequestWorkers Interacts with KeepAlive, PHP-FPM, and Reverse Proxies
KeepAlive behavior
KeepAlive can improve client performance by reusing TCP connections, but it also means some request slots stay occupied longer. Event MPM handles this scenario more efficiently than prefork, which is one reason event has become a preferred choice for many sites.
PHP-FPM architecture
If Apache proxies PHP requests to PHP-FPM, do not size Apache in isolation. PHP-FPM pools have their own concurrency and memory ceiling. A high MaxRequestWorkers value can still overload PHP-FPM or the database tier, even if Apache itself has enough RAM. Capacity planning should therefore consider the full stack, not just the web server process.
Reverse proxy and upstream latency
When Apache sits in front of application servers, each slow upstream response holds a worker slot for longer. This raises the amount of concurrency required for the same traffic volume. In such environments, request latency matters almost as much as memory. If upstream systems are slow, simply increasing MaxRequestWorkers may mask the symptom while creating more pressure on RAM and backend infrastructure.
Best Practices for Production Tuning
- Measure first. Capture average and peak worker memory during realistic traffic.
- Reserve enough RAM. Leave room for the OS, cache, database, PHP-FPM, agents, and maintenance tasks.
- Apply a safety margin. A 10% to 20% buffer is often sensible for mixed workloads.
- Align with MPM structure. For worker and event, use a ThreadsPerChild multiple.
- Load test changes. Validate new values before making them permanent.
- Monitor swap and queueing. A “successful” higher concurrency setting is not successful if latency spikes or swap rises.
One more practical point: MaxRequestWorkers is not a substitute for caching, content optimization, or application profiling. If your site is saturating Apache because requests are slow, the deeper win often comes from speeding the request path rather than just increasing the number of workers.
Authoritative Security and Operations References
For broader web server hardening and operational guidance, review these authoritative public resources:
- NIST SP 800-44 Version 2: Guidelines on Securing Public Web Servers
- CISA guidance on denial-of-service behavior and defensive planning
- CISA Cybersecurity Advisories for operational awareness and patching priorities
While these sources are not Apache-specific tuning manuals, they are highly relevant to the capacity, resilience, and security context in which MaxRequestWorkers is set. A web server that is correctly sized but poorly secured is still operationally fragile.
Final Takeaway
An Apache MaxRequestWorkers calculator is most valuable when it reflects reality rather than folklore. Start with total RAM, subtract everything Apache must share the server with, apply a safety margin, and divide by observed per-worker memory. Then refine the result based on your MPM, your keep-alive profile, and the behavior of PHP-FPM or upstream applications. That process gives you a concurrency limit that protects both performance and stability.
If you remember only one principle, remember this: the highest safe MaxRequestWorkers value is not the same as the best MaxRequestWorkers value. The best value is the one that keeps latency predictable, avoids swap, and leaves enough room for the rest of the stack to remain healthy during peak demand.