Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Nginx memory issue #77

Closed
daneren2005 opened this issue Jun 11, 2018 · 2 comments
Closed

Document Nginx memory issue #77

daneren2005 opened this issue Jun 11, 2018 · 2 comments

Comments

@daneren2005
Copy link

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.

@daneren2005
Copy link
Author

Feel free to close this if you don't want to document it anywhere as just having the issue people can search will help

@NicolasCARPi
Copy link
Sponsor Collaborator

Hello @daneren2005,

Thank you for reporting this issue. I have added your comment to the wiki:
https://github.com/maennchen/ZipStream-PHP/wiki/nginx

~Nico

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants