3

I know that prefork module in apache creates one master process and several child processes to handle connections, my question is:

Does each prefork child handles one connection or handles one request per time? and if it handles one connection does that mean that each new connection needs to wait in the queue to be handled by one of the idle child processes? and what that say about keep-alive connections?

Also i have the same question for the worker mpm module using threads?

2

Does each prefork child handles one connection or handles one request per time?

Each child / thread handles one connection (TCP connection).

Once the connection is closed, the child process will wait for another connection. On one connection one can send 0, 1 or more requests (HTTP request).

If the client doesn’t send a request, you may have a HTTP 408 time out in your logs depending on your configuration.

With KeepAlive enabled you can have more than 1 HTTP request per connection, as the connection will not be closed once the first request is served.

In the case without KeepAlive, there is 1 connection with one request, that’s why may be the question.

each new connection needs to wait in the queue to be handled by one of the idle child processes?

Yes, that is why you will configure Apache to have some idle servers / threads, so new connections do not need to wait for new child processes / threads to be created. If there aren't enough child process, new will be created as needed and according to the limits in the configuration.

So far for my own understanding of the process.

  • thanks that was very helpful. Does this apply on Nginx and asynchronous I/O?? – Hussein Galal Dec 31 '14 at 10:12
  • @Hussein No it is not the same in nginx, but I do not have enough knowledge on async servers: Just know they are handling the incoming requests much differently than Apache. This is why Apache (among others) is vulnerable to attacks making as much connections as possibles and trying to keep them open (see slowloris attack). – Zimmi Dec 31 '14 at 10:22

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.