Reputation: 314
Recently changed to php-fpm from apache php on a very old legacy codebase. Having an issue where the whole page stops rendering with no errors in fpm or apache logs.
I wrote a quick test script to reproduce the errors
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
for ($k = 0; $k < 1000; $k++) {
echo "new line: " . $k;
echo "<br>";
print_mem();
trigger_error("php-fpm error");
}
function print_mem()
{
/* Currently used memory */
$mem_usage = memory_get_usage();
/* Peak memory usage */
$mem_peak = memory_get_peak_usage();
echo 'The script is now using: <strong>' . round($mem_usage / 1024) . 'KB</strong> of memory.<br>';
echo 'Peak usage: <strong>' . round($mem_peak / 1024) . 'KB</strong> of memory. <br><br>';
}
We are currently cleaning up the legacy code but it is a lot of work, can you suggest a way to get over this limit?
Upvotes: 0
Views: 413
Reputation: 314
The problem was caused by output buffering in php
changed from 4096 to On in php.ini.
; Development Value: 4096
; Production Value: 4096
; http://php.net/output-buffering
output_buffering = On
It now renders the full loop.
I am unsure why this would cause php to stop rendering, also it is not recommended to set output_buffering to On as detailed in the php.ini.
Upvotes: 1