Welcome! Log In Create A New Profile

Advanced

Re: nginx uses high ram

John Feuerstein
January 12, 2011 08:10AM
As mentioned before, you have two options to handle application
controlled downloads:


*** 1 ***
Fix your PHP settings and code.
This is more painful than you might think(!), and many people get it wrong:

- disable PHP output buffering for the script (often enabled by
default), either via php.ini, htaccess, within the script, or
alternatively go ahead and explicitely flush buffers within the loop.

- make sure to disable PHP zlib output compression (similar effect)

- make sure to configure PHP max_execution_time and similar timeouts

- configure nginx settings for the download script location:
gzip*, fastcgi_buffer*, proxy_buffer* and various timeouts come to mind,
depending on how you communicate with PHP.



*** 2 ***
As suggested, stop useless piping of data through the PHP process and
make use of nginx's X-Accel-Redirect. Compare this to all of the stuff
above!

location /downloads/ {
internal;
alias /path/to/the/dir/containing/filename.file/;
}

<?php
header("Content-Type: application/force-download"); // or correct one
header("X-Accel-Redirect: /downloads/filename.file");
?>


Regards,
John

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx uses high ram

khizar January 12, 2011 05:31AM

Re: nginx uses high ram

John Feuerstein January 12, 2011 07:04AM

Re: nginx uses high ram

khizar January 12, 2011 07:15AM

Re: nginx uses high ram

khizar January 12, 2011 07:16AM

Re: nginx uses high ram

vt January 12, 2011 07:44AM

Re: nginx uses high ram

John Feuerstein January 12, 2011 08:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready