3
Generally, I see many people (including myself) have run-time problems with a PHP script. This is because, by default, PHP sets a deadline for running a script in 30 seconds.
These problems usually occur when PHP is working on a time-consuming request. Here the solution that is usually adopted is to increase the execution time of the script.
However, I have seen some cases where the programmer adopted as a solution define 0
for the script execution timeout (and 0
in PHP means no limits) since the waiting time could vary (for example, if the script is waiting for an external request).
My question is: If I set the time limit as 0
to make this waiting time infinite, could cause performance loss on my server?
For example, if I have multiple scripts running and waiting on average 1 minute due to a time consuming processing (be it database query, read files etc), this may cause some damage to my application in terms of performance?
It’s really safe to use set_time_limit(0)
(or any other way that exists to set a waiting time for full execution of a script as infinite)?
The other question is: Is there any reasonable or recommended time limit so I can maintain good performance of my server?
Note: When I’m talking about defining 0
, I’m talking about the function called set_time_limit
, used by many PHP programmers to increase running timeout and a script.