Output Timing Issue

Discussion in 'PHP' started by DivvyWork, Mar 9, 2010.

  1. #1
    I have an app I built for a client. It goes out and scrapes needed data. I have it hosted on a few servers on different hosts. Today I put it on a new host and the behavior has changed.

    In the past it would output the results as it found them. Now it seems to want to do all the processing and then write the output. This is a problem because the script will often time out. When the output is spit out as its found timeouts are not bad because all my clients need is to see the results. When it tries to do all the processing first and times out the results are not displayed at all. Even worse they could be sitting there for a long time before they get no results.

    I'm pretty sure this is an PHP.ini issue but I do not know the setting to change. This could also be an Apachie thing too but I'm not sure what I will do if it is.

    thanks for your help
     
    DivvyWork, Mar 9, 2010 IP
  2. BingP

    BingP Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Between the two environments, is PHP setup the same? Is one in CGI mode and the other an Apache API?

    Is the scraping occurring on a batch process (cron)?

    -Bing
     
    BingP, Mar 10, 2010 IP
  3. DivvyWork

    DivvyWork Peon

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    HI BingP,

    Thanks for the reply. When using phpinfo it seem the two setups are very similar. They are both CGI mode. This is not a cron job.
     
    DivvyWork, Mar 10, 2010 IP
  4. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    you can include this line in your php code to prevent timeout
    @set_time_limit(0);
    Code (markup):
     
    javaongsan, Mar 11, 2010 IP
  5. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Setting the time limit to 0 is a good start, but to output to the browser as it loads try this:

    
    function flush_buffers()
    {
    ob_end_flush();
    ob_flush();
    flush();
    ob_start();
    } 
    ob_start();
    
    //content
    flush_buffers();
    //content
    flush_buffers();
    //etc.etc.
    
    
    PHP:
     
    Goramba, Mar 11, 2010 IP
  6. Rory M

    Rory M Peon

    Messages:
    1,020
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Can't you just compare the two php.ini files and find every little difference and see which one is likely to be causing it?
     
    Rory M, Mar 11, 2010 IP