You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has taken me a ton of time to track down, but if you are using Nginx it can try to buffer the response. It took me many retries of just opening the request and seeing if the nginx process started steadily increasing memory usage without any stop. I do not know why this issue only happened sometimes and not others.
I am running this on Heroku and it looks like the default buildpack includes a custom buffer size of fastcgi_buffers 256 4k (https://github.com/heroku/heroku-buildpack-php/blob/master/conf/nginx/heroku.conf.php). If I am reading this correctly that means that it can buffer up to 1GB when the default web dynos max out at 500MB. While this seems like a bad config on Heroku's end, looking through Stackoverflow I saw plenty of people suggesting doing something similar so I doubt this configuration is unique to them.
My solution was to add header('X-Accel-Buffering: no'); to the streaming file and it appears to have fixed it. It could probably also be fixed by tweaking https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffers or anything else that would stop NGinx from using such large buffers for the response, but I feel like this was the easiest and the hardest to screw up the rest of the site's configuration with. Someone with more knowledge of how this stuff works can probably come up with a better solution, but I wasted hours just trying to figure out what was causing the problem in the first place.
tl;dr: I found a problem from a bad (and default on Heroku) configuration and want to possibly save others time trying to figure out WTF is going on.
The text was updated successfully, but these errors were encountered:
This has taken me a ton of time to track down, but if you are using Nginx it can try to buffer the response. It took me many retries of just opening the request and seeing if the nginx process started steadily increasing memory usage without any stop. I do not know why this issue only happened sometimes and not others.
I am running this on Heroku and it looks like the default buildpack includes a custom buffer size of
fastcgi_buffers 256 4k
(https://github.com/heroku/heroku-buildpack-php/blob/master/conf/nginx/heroku.conf.php). If I am reading this correctly that means that it can buffer up to 1GB when the default web dynos max out at 500MB. While this seems like a bad config on Heroku's end, looking through Stackoverflow I saw plenty of people suggesting doing something similar so I doubt this configuration is unique to them.My solution was to add
header('X-Accel-Buffering: no');
to the streaming file and it appears to have fixed it. It could probably also be fixed by tweaking https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffers or anything else that would stop NGinx from using such large buffers for the response, but I feel like this was the easiest and the hardest to screw up the rest of the site's configuration with. Someone with more knowledge of how this stuff works can probably come up with a better solution, but I wasted hours just trying to figure out what was causing the problem in the first place.tl;dr: I found a problem from a bad (and default on Heroku) configuration and want to possibly save others time trying to figure out WTF is going on.
The text was updated successfully, but these errors were encountered: