nginx uses high ram

John Feuerstein john at feurix.com
Wed Jan 12 15:01:05 MSK 2011


Hi,

> php read file and echo on the browser
> but nginx uses high ram

since we have no detail on how you measured this and did not show us the
PHP code (*looking at crystal ball*), I suspect it's the common problem:

If you use readfile(), make sure to disable output buffering or PHP will
happily read large files into memory until it hits the memory limit. As
an alternative, implement a chunking readfile() or use something like
http_send_file().

The most efficient way however is to use X-Accel-Redirect [1] (also
known as X-SendFile). Skip piping the file through PHP and let nginx
serve it directly!

Hope this helps,
John

[1] http://wiki.nginx.org/XSendfile



More information about the nginx mailing list