According to the documentation:max_execution_time real para PHP en Linux
max_execution_time only affect the execution time of the script itself.
Any time spent on activity that happens outside the execution of the script
such as system calls using system(), stream operations, database queries, etc.
is not included when determining the maximum time that the script has been running.
This is not true on Windows where the measured time is real.
Esto es confirmado por las pruebas:
no superará el tiempo de
<?php
set_time_limit(5);
$sql = mysqli_connect('localhost','root','root','mysql');
$query = "SELECT SLEEP(10) FROM mysql.user;";
$sql->query($query) or die($query.'<br />'.$sql->error);
echo "You got the page";
agotará el tiempo
<?php
set_time_limit(5);
while (true) {
// do nothing
}
echo "You got the page";
Nuestro problema es que realmente nos gustaría que PHP agote el tiempo de espera, independientemente de lo que esté haciendo, después de un período de tiempo dado (ya que no queremos mantener los recursos ocupados si sabemos que no hemos entregado una página en un tiempo aceptable, como 10 segundos). Sabemos que podemos jugar con configuraciones como MySQL wait_timeout para las consultas SQL, pero el tiempo de espera de la página dependerá del número de consultas que se ejecutan.
Algunas personas han intentado crear workarounds y no parece aplicable.
P: ¿Hay una forma fácil de obtener un PHP max_execution_time
real en Linux, o es mejor que se agote el tiempo en otros lugares, como el nivel Apache
?
esto no afectará al procesamiento de PHP – kuba
de hecho, he probado con Apache 'TimeOut' establecido en' 2' (segundos) y simplemente no tiene efecto alguno. ¿Hay algo más que 'mod_reqtimeout' que puedas recomendar a John? – Max