0

I've got a problem in production environment, which is running dockerized Apache with PHP-FPM (image : webdevops/php-apache).

On dev server, it run in mod-php with built-in Symfony server.

On dev server I can stream a response like so:

for($i = 0; $i < 10; $i++){
    echo 'Tick. ';
    sleep(1);
}

The server send me a "tick" every second as expected. But on production server, it wait for 10 seconds to send me the entire response.

I guess it's related to PHP-FPM scheme as it is independent from apache.

Do someone have a workaround to do the original behavior?

(In real world, I need it to use Symfony's console in a web page, and with the current scheme, it closes the request at the beginning with a single line of text, but the provided example has the same comportment as the real function).

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Nicolas G
  • 11
  • 1
  • servers sometimes wait til the current packet is filled to a certain level or a certain time. technically there should be a method to flush the packets early ... perhaps https://php.net/flush ... well it at least gives you some pointers I guess. – Jakumi Aug 30 '19 at 20:39
  • You probably need to disable output buffering in the container. https://www.jeffgeerling.com/blog/2016/streaming-php-disabling-output-buffering-php-apache-nginx-and-varnish – Alex Barker Aug 30 '19 at 21:30
  • This question is rather old, but I have nearly the same problem except that I don't use container (everything runs on the same machine) and output buffering is already disabled (so my setup excludes some of the obvious pitfalls). I wonder the OP already has found a solution and post the answer here? – user2690527 Jan 06 '22 at 14:32

0 Answers0