Generally, I see a lot of people (including myself I've had) run-time issues with a PHP script. This is because, by default, PHP sets a time limit for running a script in 30 seconds.
These problems usually occur when PHP is working on a lengthy request. Here the solution that is usually adopted is to increase the execution time limit of the script.
However, I have seen some cases where the programmer has chosen to set 0
to the script execution timeout (and 0
in PHP means without limits) since the wait time could vary (for example, if the script is waiting for an external request).
My question is: Should I set the timeout as 0
to make this timeout infinite, could it cause performance loss on my server?
For example, if I have multiple scripts running and waiting for an average of 1 minute, due to a time-consuming process (ie, database querying, etc.), can this lead to my application being affected in terms of performance?
Is it really safe to useset_time_limit(0)
(or any other way that exists to set a wait time for a complete execution of a script to be infinite)?
The other question is: Is there any reasonable or recommended time-out so I can maintain good performance on my server?
Note : When I'm talking about setting 0
, I'm talking about the function named set_time_limit
, used by many PHP programmers to increase execution timeout and a script.