Apache Process-Killing Strategy

I'm looking for documentation regarding when Apache will decide to kill a child process. Most of this is to satisfy my curiosity, because it doesn't seem something that's discussed much.

Let's put MaxRequestsPerChild aside. The documentation is clear on that– after so many requests, the child process dies. On my server, I've set this to 1000 out of paranoia regarding memory leaks (in PHP and WordPress). So presumably after servicing 1000 requests, I should see the child process die.

But here's the confusing/under-documented part: My web server isn't hugely busy, so hitting 1000 requests is going to take some time. And I'm seeing child processes die well before that.

At any time, I usually have 10 child processes (MaxSpareServers) hanging around. When a surge of activity comes in, the connection backlog will grow and Apache cranks up the number of processes to handle the connections. I'll see a maximum of 32 child processes appear (ServerLimit). But within a few seconds, the number of processes will start to drop until it again gets back to the 10 child processes.

Again, it would take quite a time for the 1000 MaxRequestsPerChild to hit these processes and kill them. So what is Apache's process killing strategy? Under what other conditions will Apache kill processes?

3 Replies

Apache kills idle servers if there's more than MaxSpareServers of them, and spawns idle servers if there's less than MinSpareServers of them. Simple. Spawning both idle spares, and busy processes is constrained by the hard value of ServerLimit.

It's all in the mpmprefork documentation. Well, it's a bit similiar with mpmworker, sub-server processes and threads in them, you just get two levels of regulation there so it's a bit more complex.

@rsk:

Apache kills idle servers if there's more than MaxSpareServers of them, and spawns idle servers if there's less than MinSpareServers of them. Simple. Spawning both idle spares, and busy processes is constrained by the hard value of ServerLimit.

So I guess I'm asking what the definition of "idle" is then. Is it literally the moment when the process either has no longer has a connection (or if KeepAlive is on, until the timeout occurs)? Or does Apache add a fudge factor beyond that and consider a process idle after some about time without activity?

Well, the documentation doesn't mention any delays. > The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes. Doesn't mean there isn't one, of course. But I think that's a question that would be better answered on the Apache mailing list. ( http://httpd.apache.org/lists.html )

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct