You are here:  » Large feeds


Large feeds

Submitted by nutkenz on Wed, 2007-07-25 08:43 in

Parsing a large file (136MB) fails... It simply times out. How could I resolve this? The limits in php.ini are already generous with the system resources:

max_execution_time = 3600000 ; Maximum execution time of each script, in seconds
max_input_time = 3600000 ; Maximum amount of time each script may spend parsing request data
memory_limit = 10240M ; Maximum amount of memory a script may consume (16MB)

Submitted by support on Wed, 2007-07-25 09:20

Hi,

The usual solution to a simple timeout problem is to add the following code to the top of the script:

set_time_limit(0);

This should work if your timeout is described as that by PHP in the error message that is displayed. Make sure that error reporting is turned on so that you can see what caused the script to stop execution.

The secondly possibility is that the timeout is not at your server - it could be a proxy server at your ISP that has timed out waiting for the response. In this case, the solution is to make sure that your script is generating output and regularly flush()'ing that output to try and push it as far as the browser.

The third possibility is that Apache is configured to timeout waiting for a PHP script to execute, which is nothing to do with PHP's internal timeout mechanism (as you say it is given ages in php.ini). The usual evidence of this is the request just finishing with a blank screen. If this is the case, it is usually necessary to contact your host and explain that you are running scripts that will take several minutes to complete and could you have the Apache timeout removed against your account.

As a final test, in these situations I always confirm that the actual parsing function is behaving as expected. To do this, insert a print statement into your record handler function, and then exit() the script, for example:

<?php
  
function myRecordHandler($record)
  {
    print 
"Got first record.";exit();
  }
?>

If you do not see "Got first record." displayed by your script, then it would indicate that an incorrect format string is being used in the call to MagicParser_parse().

Hope this helps,
Cheers,
David.