Why cannot Apache handle multiple requests at the same time?

Probably becouse of sessions locking. When you don't need to edit session variables, close it.

http://php.net/manual/en/function.session-write-close.php


manipulate yours sessions, write on start of script.php

// manipulate writes, and unlock session file!
session_start();
$_SESSION['admin'] = 1;
$_SESSION['user'] = 'Username';
session_write_close(); // unlock session file, to another script can access

// start your script without php session block
sleep(30); 
echo $_SESSION['user'];

// another script can run without wait this script finish

Apache can surely handle multiple requests at the same time, there is something surely going wrong within your apache configuration.

It depends on which version of Apache you are using and how it is configured, but a common default configuration uses multiple workers with multiple threads to handle simultaneous requests. See http://httpd.apache.org/docs/2.2/mod/worker.html for a rundown of how this works.

The reason why you are facing it is: There is some lock somewhere - which can happen, for instance, if the two requests come from the same client, and you are using file-based sessions in PHP : while a script is being executed, the session is "locked", which means the server/client will have to wait until the first request is finished (and the file unlocked) to be able to use the file to open the session for the second user.

The requests come from the same client AND the same browser; most browsers will queue the requests in this case, even when there is nothing server-side producing this behaviour.

Tags:

Php

Apache

Ampps