Can any confirm how Apache spawns new children ?

As in if I connect to a webserver (HTTP 1.0 / no keep alive) and issue a HTTP /GET I will be spawned a new HTTPD child. If then issue another HTTP /GET then a new TCP connection will be built. However will I use the same child process of would I spawn a new one ?

Also if I was using HTTP 1.1 (with keep-alive) and reused the same TCP connection, would the httpd process/spawning be any different to that if I wasnt using keepalive ?



if I connect to a webserver (HTTP 1.0 / no keep alive) and issue a HTTP /GET I will be spawned a new HTTPD child

No, for the TCP handshake to complete, you've already got a process to handle your request. Since you mention 'processes' this implies you're talking about pre-fork MPM. In which case, the server should already have a pool of available child processes - one of these acquires a mutex to pick up the next incoming connection.

The thread based server works in a similar manner.

The event based server is a completely different kettle of fish and doesn't spawn threads/processes.

If then issue another HTTP /GET...will I use the same child process

No. And even if you know that you have a keepalive connection, there is no state retained by the server - hence you have to treat it as if it were a new process.

  • No - how do you get that from my answer? – symcbean Nov 29 '12 at 9:18

There is no universal setting, as this is the most crucial aspect of http server's performance. Generally, Apache tries hard to avoid forking (or spawning, as you've called it). Check this out:


Multi-Processing Modules (MPMs) are Apache modules that manage the network connections and dispatching the requests. There are two common MPMs available for Apache2, namely, mpm_prefork_module and mpm_worker_module. The mpm_prefork_module uses the traditional model of one process per request, while the mpm_worker_module uses the threaded model which uses multiple processes, each with multiple threads to get better performance with lower overhead.

Manuals for Apache 2.4 says:

When building Apache, you must choose an MPM to use. There are platform-specific MPMs for some platforms: mpm_netware, mpmt_os2, and mpm_winnt [for any MS Windows version]. For general Unix-type systems, there are several MPMs from which to choose. The choice of MPM can affect the speed and scalability of the httpd:

  • The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.
  • The event MPM is threaded like the Worker MPM, but is designed to allow more requests to be served simultaneously by passing off some processing work to supporting threads, freeing up the main threads to work on new requests.
  • The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time.
  • Yep I am using prefork. So if I have this right a new TCP connection is assigned to a new process. However I would of thought it would be better for it to use an exsisting process ? – felix001 Nov 26 '12 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.