Can setting run-time to infinity affect server performance?

Asked

Viewed 4,279 times

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.

2 answers

3

Can compromise performance yes.

Setting the run limit to ZERO can cause slowdowns or even crashing your server.

See the maximum time needed, then set a slack.

Is there any reasonable or recommended time limit so I can maintain good performance of my server? There is no rule for this, it depends on your environment, your server resources, system, clients, usage, etc.

See your need for time and set a slack. But I don’t recommend leaving NO LIMIT.

2


If I set the timeout to 0 to make this waiting time infinite, it could cause performance loss on my server?

Regardless of the scenario, I think the set_time_limit(0) is not a good practice. That if your system gives some bug, the script will run and it will "end" with memory. That is, it will hurt the principle of efficiency, defined by ISO 9241.

Is there any reasonable or recommended time limit so I can maintain good performance of my server?

On the part of documentation contribution says that your web server can catch you with an HTTP imposed time limit (usually about 5 minutes). You should check the web server tabs for more information about HTTP timeouts.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.