Nginx + PHP maximum output limit

I have php 5.5 (fpm) and nginx 1.10 installed (gzip configured to 1). Running on ubuntu.

When I am "echoing" a large output (over 2 mb), it stops abruptly at around 520 kb.

But same program when I run on php-cli, it has no problem "echoing" the whole thing onto the terminal.

Also downloading mysql dumps through adminer gets stopped in the half way. I mean incomplete files get downloaded (if the correct total output is bigger in couple of MBs).

How to fix this?

There is nothing wrong with my program. Even a simple long enough for loop spurting out echo "hello world" gets stopped at specific byte limit.

I am not sure if this issue is caused from nginx side or php side.


Solution 1:

Try disabling buffering:

fastcgi_buffering off;

It's on by default.

This will give you a bit more control from within PHP, but be aware that flushing operations that didn't block previously may now block. It will also overcome any buffering issues Nginx may be encountering--I'd put my money on that being the issue. Nginx's buffers are efficient but fickle.