Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Apache "server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting": measure before you raise it

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When Apache writes server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting to its error log, every worker was busy at that moment and new connections were waiting for one to finish. The message is only a symptom. Before you raise the number, find out why the workers are busy and how much memory one worker process costs, because a limit above what the machine can hold turns a queue into swapping.

What the symptom means

The Apache documentation says MaxRequestWorkers "sets the limit on the number of simultaneous requests that will be served" and that connection attempts over the limit "will normally be queued, up to a number based on the ListenBacklog directive". The queue length is set by ListenBackLog, whose default is 511, and the page adds that the operating system often limits it to a smaller number.

What a "worker" is depends on the MPM, the module that manages processes:

  • prefork: one process per request. MaxRequestWorkers is the maximum number of child processes. The default is 256, and to raise it you must also raise ServerLimit.
  • worker and event: each child process runs a fixed number of threads, set by ThreadsPerChild (default 25). MaxRequestWorkers limits the total threads. The default is 16 (ServerLimit) multiplied by 25 (ThreadsPerChild), which is 400. The number of processes is MaxRequestWorkers divided by ThreadsPerChild.

The message text and its log codes come from the source code (Apache httpd 2.4.71, prefork.c, worker.c, event.c), not from the documentation pages: AH00161 in prefork, AH00286 in worker and AH00484 in event. The worker and event MPMs also log a second message, server is within MinSpareThreads of MaxRequestWorkers, consider raising the MaxRequestWorkers setting (AH00287 and AH10159), when idle threads are few but not zero. In each of those 2.4.71 source files the message is guarded by a flag that is set after the first report and not cleared again in that file, so the line appears once while that server run continues, and a quiet log does not mean the problem has stopped. Because the flag is never reset, a full stop and start begins a new run, which can log the line again.

Likely causes

Cause What you see How to confirm
Real peak load above the limit Many short requests, all slots busy at peak, quiet otherwise The server-status page shows most workers busy with requests that finish quickly
Slow requests hold the workers The same requests stay in a worker for a long time (the event page names long-running requests, slow clients and keep-alive connections) The server-status page shows long-running requests; the mod_status page says that you will often identify "a particular web application that is misbehaving, or a particular client"
One client or crawler occupies many workers Most busy workers show the same client address The server-status page with ExtendedStatus on lists client and request for each worker
Event MPM: old processes still finishing after a graceful restart Slots look full but active requests are fewer than MaxRequestWorkers The event page describes threads stuck in the Graceful state after a graceful restart, blocking new requests that are queued instead
Limit set below what the memory allows The log message while free -m shows plenty of available memory Divide usable memory by process size (below) and compare with the configured limit
Limit set above what the memory allows Swapping and slow responses free -m shows little available memory; if a service was killed for lack of memory, see Linux OOM Killer on a VM: Find the Cause, Set Memory Limits

Prove the cause before changing anything

All of these are read-only.

1. Which MPM is running. The httpd manual page says -M dumps the loaded static and shared modules and -l lists modules compiled in:

apachectl -M
apachectl -l

Look for the module named event, worker or prefork (the prefork page shows mpm_prefork_module).

2. What the limits are now. Read the configuration files for MaxRequestWorkers, ServerLimit and ThreadsPerChild. A directive that is absent uses the default given above. MaxRequestWorkers was called MaxClients before version 2.3.13, and the page says the old name is still accepted, so search for both.

3. What the workers are doing. The mod_status page lists among its details "The number of workers serving requests" and "The number of idle workers", and, with ExtendedStatus on, the host and request each worker is handling. Loading mod_status turns ExtendedStatus on by default from version 2.3.6. If mod_status is already enabled, apachectl fullstatus prints the report; the apachectl page says it needs a text-based browser such as lynx. The machine-readable form is the ?auto page:

http://your.server.name/server-status?auto

A good result is a mix of busy and idle workers with requests that change between refreshes. A bad result is every worker busy with the same slow request or the same client. The page says you may need several refreshes.

4. How large one process is. The performance page gives the method: determine "the size of your average Apache process, by looking at your process list" and divide it into total available memory, "leaving some room for other processes". The ps manual page defines rss as the non-swapped physical memory a task has used, in kibibytes:

ps -C httpd -o pid,rss,cmd
free -m

Use the program name your system shows for Apache in -C. free -m prints mebibytes; its available column estimates the memory free for new applications without swapping. Divide each rss value by 1024 for mebibytes.

5. Whether the memory is already short. If free -m shows little available memory while Apache is busy, do not raise the limit. The prefork page says sites with limited memory may need to decrease MaxRequestWorkers to keep the server from "thrashing (swapping memory to disk and back)".

Fix

Slow requests or one client

Raising the limit does not shorten a slow request. If step 3 shows workers held by long-running requests, find what makes them slow, as in PHP-FPM Has Reached pm.max_children: Measure Queueing Before Adding Workers. If one client holds many workers, block or limit that client at the firewall or proxy, not in Apache's worker count.

Enable the status page (only if step 3 had no data)

First save the current file:

cp -p /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.2026-11-22

Risk: the next edit exposes server statistics, client addresses and request lines at a web address, and the commands that follow it gracefully restart Apache, which asks every child process to exit after its current request and re-reads the configuration. The Apache page warns that the handler is "available in all configuration files" once the module is loaded, "including per-directory files", which "may have security-related ramifications".

Add the block the Apache page gives, restricted to an address you control. Replace the host with your own administration address:

<Location "/server-status">
    SetHandler server-status
    Require host example.com
</Location>

Check the syntax, then apply it with a graceful restart, which the apachectl page says does not abort currently open connections:

apachectl configtest
apachectl graceful

To undo it: put the saved file back, check it, and gracefully restart again.

cp -p /usr/local/apache2/conf/httpd.conf.2026-11-22 /usr/local/apache2/conf/httpd.conf
apachectl configtest
apachectl graceful

Real load: raise the limits from the memory budget

Memory for Apache divided by one child's size gives the children for prefork, or the processes for event and worker; for those, MaxRequestWorkers is the processes multiplied by ThreadsPerChild.

Example (illustrative): web01 runs the event MPM with the defaults: ThreadsPerChild 25, ServerLimit 16, so MaxRequestWorkers is 16 x 25 = 400. The status page shows 400 busy workers at the afternoon peak. free -m shows 8,192 MiB; reserving 3,392 MiB for everything else leaves 4,800 MiB for Apache. ps shows an average child rss of 122,880 KiB, or 120 MiB. The memory holds 4,800 / 120 = 40 processes in total, including old processes finishing after a graceful restart. Keeping 8 of the 40 as room for those leaves 32 active processes, so MaxRequestWorkers = 32 x 25 = 800 and ServerLimit = 40. The MaxRequestWorkers entry on the mpm_common page says it "should be an integer multiple of ThreadsPerChild"; 800 / 25 = 32.

The ServerLimit page says that for event you should increase it when the processes defined by MaxRequestWorkers and ThreadsPerChild, "plus the number of gracefully shutting down processes", exceed the default 16. A value higher than needed allocates unused shared memory.

First save the current file:

cp -p /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.limits.2026-11-22

Risk: the next edit raises the number of processes Apache may start. A value above what your memory supports makes the server swap, and the Apache page says that if both ServerLimit and MaxRequestWorkers are higher than the system can handle, "Apache httpd may not start or the system may become unstable".

Set the directives in the file that holds them, using your own computed values (the example's, for event, are shown). On prefork, set only ServerLimit and MaxRequestWorkers, both to the process count you computed, because the prefork page lists no ThreadsPerChild:

ServerLimit 40
ThreadsPerChild 25
MaxRequestWorkers 800

Check the syntax:

apachectl configtest

To undo the edit before you apply it: put the saved file back and check it. The stop and start below put the change live, and a second undo follows them.

cp -p /usr/local/apache2/conf/httpd.conf.limits.2026-11-22 /usr/local/apache2/conf/httpd.conf
apachectl configtest

Apply a changed ServerLimit

The ServerLimit page says "Any attempts to change this directive during a restart will be ignored", while MaxRequestWorkers "can be modified during a restart". A graceful restart therefore applies a new MaxRequestWorkers only within the old ServerLimit. Applying a new ServerLimit takes a full stop and start.

First save the list of loaded modules, so you can compare it after the start:

apachectl -M > /root/apache-modules-2026-11-22.txt

Disruptive step: the next commands stop Apache. The stopping page says that any requests in progress are terminated and no further requests are served until it is started again.

The apachectl page says restart and graceful check the configuration automatically and says nothing like that for stop and start, so check it first:

apachectl configtest

Run the stop command only if apachectl configtest reported no error:

apachectl stop

The apachectl page says start gives an error if Apache is already running. Check that no Apache process is left, and run apachectl start only when the list shows no process lines, only the PID CMD header:

ps -C httpd -o pid,cmd

Use the program name your system shows for Apache. Then start it and compare the modules with the saved list:

apachectl start
apachectl -M

To back out after this change: restore the configuration file saved before the limits edit, check it, then stop and start again, with the same process check between them.

cp -p /usr/local/apache2/conf/httpd.conf.limits.2026-11-22 /usr/local/apache2/conf/httpd.conf
apachectl configtest

Run the stop command only if the test reported no error:

apachectl stop

Check that no Apache process is left, and run apachectl start only when the list shows no process lines, only the PID CMD header:

ps -C httpd -o pid,cmd

Then start it:

apachectl start

Confirm the fix

  1. tail -f on the error log (the stopping page gives tail -f /usr/local/apache2/logs/error_log as the form; use your own ServerRoot) shows no new server reached MaxRequestWorkers line after the peak.
  2. The status page at peak shows some idle workers.
  3. free -m at peak shows memory available and no swap growth.

What to watch afterwards

  • Recalculate after a code or module change, since process size changes.
  • Watch busy workers at peak, not only the log line, because the message appears once.
  • If response times rise while workers stay busy, look at the long-running requests on the status page first; a higher worker count does not shorten them.

Risks and limits

  • These commands have not been run or lab-tested.
  • Paths such as /usr/local/apache2/conf/httpd.conf come from the Apache documentation's examples. Your distribution may keep the file elsewhere and split the settings across several files; save and restore the file that holds the directive.
  • Apache's documentation gives no formula beyond dividing memory by process size. Treat the result as a starting value and measure again at peak.

Sources

  • mpm_common: MaxRequestWorkers, ServerLimit, ThreadsPerChild, ListenBackLog — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • event MPM — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • prefork MPM — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • mod_status — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • Apache performance tuning — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • Stopping and restarting Apache HTTP Server — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • apachectl — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • httpd — Apache HTTP Server 2.4 documentation, no date shown, accessed 22 November 2026
  • event.c, tag 2.4.71 — Apache httpd source code, fixed tag 2.4.71, no date shown, accessed 22 November 2026
  • prefork.c, tag 2.4.71 — Apache httpd source code, fixed tag 2.4.71, no date shown, accessed 22 November 2026
  • worker.c, tag 2.4.71 — Apache httpd source code, fixed tag 2.4.71, no date shown, accessed 22 November 2026
  • ps(1) — procps-ng manual page, 2025-04-23, accessed 22 November 2026
  • free(1) — procps-ng manual page, 2023-05-02, accessed 22 November 2026
  • cp(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026