Php – How does Apache process several requests at a time

apache-2.2multi-threadingPHP

If 10 requests hit Apache, does it process them one by one, so when R3 finishes, then it starts to run R4, or does it fire 10 processes/threads/whatever and are resolved simultaneously?

Now some background: I have a PHP script that takes up to two minutes to do some processes. My question is: while a client is waiting for this 2 minutes, all the other clients requests are being processed? Or also waiting for this one to end?

By the way, if there are simultaneous request, how can I handle them? Let's say put a limit on them. Or a limit on resources consumed. For instance I want the server to use its 80% performance on serving the webapp, and just a 20% for those long operations, because I have no hurry to end them.

I don't know if it matters, but is all in PHP.

Best Answer

The server handles requests concurrently up to a limit which you set in the configuration file. Have a look at these directives:

MinSpareThreads
MaxSpareThreads
ThreadsPerChild
MaxClients
MaxRequestsPerChild