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 ?
Thanks,
Best Answer
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.
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.