I have a WordPress installed and I use a web form to upload images in my web site. The web form allowing the end user to upload more than one files at a time.

The problem is that one of my users had that error :

Fatal error: Maximum execution time of 30 seconds exceeded in /home/ACOUNT/public_html/wp-includes/media.php on line 258

So what is the best tuning for max_execution_time. Now as you can see is 30 seconds. Any idea please?

If I set that in a very high value (ie 600) will that affect my server performance ?

Note: the user had try to upload two files, with sizes of 2.96MB and 2.9MB.

Kind regards Merianos Nikos


I'm guessing from the path in the error message that this is a Unix/Linux system (MSWindows handles the timeout very differently).

While bandwidth (and latency!) has a big impact on the time taken to process the request, the PHP clock only starts when the PHP interpreter is invoked - this won't be until the webserver has received a complete request - i.e. the PHP execution time and hence the timeout should have nothing to do with how long it took for the webserver to process the request.

There is a timeout in PHP to determine how long it should spend receiving data from the webserver - max_input_time - and it has been reported that when this is exceeded it reports max_execution_time exceeded!.

So....assuming a 0 latency network...

  • 00:00 user starts upload, apache timeout clock starts (but will keep getting reset by new packets arriving)

  • 00:10 receiving of request completed by Apache, request handed over to PHP, max_input_time clock started

  • 00:11 PHP has read all the input, max_input_time clock is stopped, max_execution_time clock started, script is executed

Now since on a Unix box, the max_execution clock only ticks when the PHP is executing, the problem is with PHP's performance / the performance of the PHP script.

Yes, you can increase the max execution time without it having a big impact elsewhere (although setting it via ini_set() / set_time_limit() on a script by script basis is neater than a global setting). But do make sure you're using an opcode cache, and if the php script is trying to parse the data, do beware of data / parser issues.

| improve this answer | |

There are two purposes of the max_execution_time setting:

  1. Protecting you from bad code, such as infinite loops.
  2. Stopping PHP from wastefully processing after it is guessed that the client has already given up.

Setting it to a high value will only affect performance if you have scripts that do one of the above two things.

Check your error logs to see how often (if at all) you exceed this time before changing it.

You can selectively change it by using ini_set() in the PHP code that requires more time.

| improve this answer | |
  • 2 above only applies with ignore_user_abort(true) - and where that's the case you probably want the script to complete anyway. – symcbean Mar 28 '12 at 11:22

As @Ladadadada says, max_execution_time setting wont affect your server performance. Otherwise, if you don't want to set a too high value, I personnaly refer to the upload_max_filesize setting.

Knowing your server bandwith and by testing a few uploads, you'll be able to find an average upload rate (reduce that rate to take care of users who have a low bandwith). This would help to set a reasonnable max_execution_time value.

| improve this answer | |
  • The upload_max_filesize HTML property is ignored by most (all?) browsers - it's a PHP thing - all you're doing is changing the behaviour of the PHP after the file has been sent - you can force an error on msot webserver (before the request is handed off to PHP) by limiting the POST size. – symcbean Mar 28 '12 at 11:21
  • Doesn't known upload_max_filesize HTML property exists. I referenced the upload_max_filesize php.ini setting. I tought that this setting was overriding the POST size. Am i wrong ? – aschuler Mar 28 '12 at 12:22
  • No - the POST limit imlpemented by the webserver is still in place - it just means that PHP will abandon the writing of the temporary file (and omit the remainder of entries in $_FILE) when exceeded. The uploads section in the manual describes adding a form element named MAX_FILE_SIZE - but this appears to be just wishful thinking - see php.net/manual/en/features.file-upload.post-method.php – symcbean Mar 28 '12 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.