nginx uses high ram

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


> 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

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,


More information about the nginx mailing list