Search code examples
phpapachezend-frameworkhttp-redirectredirect-loop

Does my ZF app cause "request exceeded the limit of 10 internal redirects" errors?


We've an eCommerce site developed with ZendFrameWork v1.10. Sometimes site is loads extremely slowly, and many pages are not loading at all and are timing out. The homepage is taking upwards of 15 seconds to load, and many product pages do not load at all and simply time out.

Often times for this case we restart our apache server and site up as normal . Then we inquired the server providers they said our server health is good and they produce our server health status as like this

(~) # uptime
 12:00:17 up 655 days, 10:51,  2 users,  load average: 0.87, 0.65, 0.58

(~) # uptime
 12:00:29 up 177 days,  6:46,  1 user,  load average: 0.64, 0.53, 0.47

Also they advised us to check our server error_log because they found many php errors are loading to it. When we checking the server erro_log and it's old files. We found many of the following error in all our log files.

[Sun Dec 30 02:35:32 2012] [error] [client 66.249.76.16] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

If I checked the above error for certain IP in the error_log file eg : 66.249.76.16 I found 6 results and if I checked the IP stripping off the last two digits from it (66.249.76) I can see more than 20 errors per day like above in our error_log file.

I think, the first problem I should solve is the above "Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace" Apache log problem.

We have gone through logs and it happens daily as mentioned above, so I need to find out what code is actually causing this bug. We asked our server support to enable "Loglevel debug" (I'm not too familiar with this) but I still cannot see anything useful or any difference in our error log after enabling this.

My question is - what can I do to find out where in our site this error is being generated? It would be very helpful to know which PHP script (we have 100s) is actually making this "Request exceeded the limit of 10 internal redirects" redirect happen.

Any recommendations of how I can proceed?


Solution

  • We also had some issues like this. We made a log in the index.php, which gave us a pretty good idea which request is causing the issue. You can implement the same and check from which requests are taking most execution time.

    <?php
    
    define('EXECUTION_START',  microtime(true));
    
    .
    .
    .
    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH .DS. 'configs'.DS.'application.ini'
    );
    $application->bootstrap()
                ->run();
    
    $endTime = microtime(true);
    $executionTime = $endTime-EXECUTION_START;
    $ipaddress = $_SERVER['REMOTE_ADDR'];
    $url = $_SERVER['REQUEST_URI'];
    
    $logString="$ipaddress|$url|$startTime|$endTime|$executionTime\n";
    $file = 'executiontime.txt';
    file_put_contents($file, $logString, FILE_APPEND | LOCK_EX);