Discussion:
[PHP-INSTALL] max_execution_time - fpm setup with nginx
Amod Pandey
2013-01-04 15:09:26 UTC
Permalink
Hi,

I have configured max_execution_time = 30 in php.ini. There is no place it
is altered.

We are running php-fpm with nginx.

If request_terminate_timeout is NOT set in the php-fpm then the script does
not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.

Is this expected or anything wrong?
--
Amod
Ferenc Kovacs
2013-01-04 16:21:05 UTC
Permalink
hi,

http://php.net/set_time_limit
see the note:
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the limit
of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what does
your script doing, it will terminate the script after the set amount of
time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no place it
is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Amod Pandey
2013-01-04 16:38:47 UTC
Permalink
This is my code. And it continues to run. It should have stopped after
completion of the while loop.

php v 5.3.13

<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what does
your script doing, it will terminate the script after the set amount of
time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no place
it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
Ferenc Kovacs
2013-01-04 16:45:27 UTC
Permalink
your code can run more than 30 seconds because (as I mentioned before and
linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what does
your script doing, it will terminate the script after the set amount of
time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no place
it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Amod Pandey
2013-01-04 16:48:06 UTC
Permalink
But it should stop at while ( I assume, else this setting is useless )? But
it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before and
linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what does
your script doing, it will terminate the script after the set amount of
time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no place
it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
Miles Thompson
2013-01-04 17:00:04 UTC
Permalink
You don't exit() out of the loop. while(true) is behaving exactly as it
should.
M.
Post by Amod Pandey
But it should stop at while ( I assume, else this setting is useless )?
But it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before and
linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what
does your script doing, it will terminate the script after the set amount
of time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no
place it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Miles Thompson
~~~~~~~~~~~~~~~~~~~~~~~~~~
"The piano keys are black and white,
But they sound like a million colours in your mind"
Spider's Web - Katie Melua
Amod Pandey
2013-01-04 17:04:42 UTC
Permalink
M: I hope you haven't read the question!
Post by Miles Thompson
You don't exit() out of the loop. while(true) is behaving exactly as it
should.
M.
Post by Amod Pandey
But it should stop at while ( I assume, else this setting is useless )?
But it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before
and linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what
does your script doing, it will terminate the script after the set amount
of time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no
place it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the
script does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Miles Thompson
~~~~~~~~~~~~~~~~~~~~~~~~~~
"The piano keys are black and white,
But they sound like a million colours in your mind"
Spider's Web - Katie Melua
--
Amod
Ferenc Kovacs
2013-01-04 17:00:52 UTC
Permalink
maybe this can help to understand: from the php's execution time point of
view, sleep(5) is seen as a(n almost) zero cost operation.
so if you have 30 secs execution time limit set, calling sleep(5); wouldn't
reduce the time left by 5 seconds, but only some microseconds, so you would
still have almost 30 seconds left to go.
more on that topic:
http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time
Post by Amod Pandey
But it should stop at while ( I assume, else this setting is useless )?
But it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before and
linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what
does your script doing, it will terminate the script after the set amount
of time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no
place it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the script
does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Amod Pandey
2013-01-04 17:09:01 UTC
Permalink
In any case it should stop in max 30 seconds, or a minute or 5 minutes, how
much ever time any operation spends!! But it never stops! It there
something which I am really not getting here?
Post by Ferenc Kovacs
maybe this can help to understand: from the php's execution time point of
view, sleep(5) is seen as a(n almost) zero cost operation.
so if you have 30 secs execution time limit set, calling sleep(5);
wouldn't reduce the time left by 5 seconds, but only some microseconds, so
you would still have almost 30 seconds left to go.
http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time
Post by Amod Pandey
But it should stop at while ( I assume, else this setting is useless )?
But it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before
and linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what
does your script doing, it will terminate the script after the set amount
of time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no
place it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the
script does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
Ferenc Kovacs
2013-01-04 17:36:25 UTC
Permalink
yes, it is.
as I've mentioned, calls like sleep() or mysql_query() or exec() isn't
counted towards the execution_time as they spend the time outside of php.
maybe you think that php does something similar as checking the wall time
at the start of the script and comparing that to the current wall time at
each instruction.
that's not the case. php will only count the user time (simplifying things
here) spent in the php process itself.
calling external resources like sleep and exec won't count towards the php
process' user time.
Post by Amod Pandey
In any case it should stop in max 30 seconds, or a minute or 5 minutes,
how much ever time any operation spends!! But it never stops! It there
something which I am really not getting here?
Post by Ferenc Kovacs
maybe this can help to understand: from the php's execution time point of
view, sleep(5) is seen as a(n almost) zero cost operation.
so if you have 30 secs execution time limit set, calling sleep(5);
wouldn't reduce the time left by 5 seconds, but only some microseconds, so
you would still have almost 30 seconds left to go.
http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time
Post by Amod Pandey
But it should stop at while ( I assume, else this setting is useless )?
But it does not stop. It runs indefinitely unless I kill it !!
Post by Ferenc Kovacs
your code can run more than 30 seconds because (as I mentioned before
and linked you to the manual page) external calls including(sleep) doesn't
counted into the execution time of set_time_limit.
Post by Amod Pandey
This is my code. And it continues to run. It should have stopped after
completion of the while loop.
php v 5.3.13
<?php
while(true) {
$file = fopen("test.txt","w");
$d=date('H:i:s');
echo fwrite($file,"$d");
fclose($file);
sleep(5);
}
?>
Post by Ferenc Kovacs
hi,
http://php.net/set_time_limit
"The set_time_limit() function and the configuration directive
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."
which means that your script can took more than 30 seconds before the
limit of max_execution_time kicks in.
request_terminate_timeout on the other hand doesn't care about what
does your script doing, it will terminate the script after the set amount
of time.
Post by Amod Pandey
Hi,
I have configured max_execution_time = 30 in php.ini. There is no
place it is altered.
We are running php-fpm with nginx.
If request_terminate_timeout is NOT set in the php-fpm then the
script does not stop!! Even though the browser times out with 504. If I set
request_terminate_timeout the php process timesout at the specified time. I
was assuming the php script will timeout at 30 seconds.
Is this expected or anything wrong?
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
--
Amod
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
Loading...