Page 1 of 1

web server: low memory web server -> Nginx + Php-fpm

PostPosted: Sun Dec 28, 2014 1:53 pm
by andre1
It seems you use Apache with Mod_php in the firmware.
Apache + php memory footprint is a lot higher than today's alternatives.

There is a very fast and low memory alternative, for instance, Nginx + Php-fpm.
Besides since a NAS has very few http requests nginx master process can be tuned to use very very few memory on standby (like 2-3MB) and php-fpm master process to (3-5MB).

Re: web server: low memory web server -> Nginx + Php-fpm

PostPosted: Mon Dec 29, 2014 10:07 am
by fvdw
thanks for the suggestion :thumbup we will have a look at it but some applications (mods) of apache are used in the firmware. With a nas with 128MB or more RAM the footprint is not big of a problem, but we also have the nwsp1 and spd8020 with only 16MB that may benefit from it.

ps Apache also doesn't use so much memory in standby, or it is swapped when not in use

I already saw one problem Nginx is not free

Re: web server: low memory web server -> Nginx + Php-fpm

PostPosted: Mon Dec 29, 2014 2:01 pm
by andre1
nginx is free and open source, the "plus" version is not.
The "plus" version has some more capabilities like some types of streaming and support, but i use the free version for over a year and it's very good!
See here: http://nginx.com/products/feature-matrix/

http://nginx.org/en/download.html

Reggarding nginx memory usage see my stats:
Code: Select all
$ psmem.sh nginx
Number of processes = 3
Memory usage per process = 1.80599 MB
Total memory usage = 5.41797 MB

And i have a "cache manager process", that is this case is not needed and can be disabled

Code: Select all
nginx: master process
nginx: worker process
nginx: cache manager process


Besides my release of nginx in the one prebuilt for CentOS

Code: Select all
# nginx -V
nginx version: nginx/1.7.9
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
TLS SNI support enabled
configure arguments: [...]
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-http_auth_request_module
--with-mail
--with-mail_ssl_module
--with-file-aio
--with-ipv6
--with-http_spdy_module
[...]'


It could be build with less modules and have even lower memory footprint (each module is explained in http://nginx.org/en/docs/).

The thing is if you have no experience with nginx is the arquitecture is very different from apache.

Nginx is built for performance, there is no htaccess files, all folders config is the conf directory, nginx doesn't have shared modules like apache, only built in modules. So there is no PHP (or other CGI module), nginx redirects this requests to a cgi process that is listening in another unix socket (faster) or tcp port, and for php that is php-fpm.

Nginx is more like a static files webserver with proxy to other services/cgi.
This arquitecture makes it very fast and with very low resources.
Lighttpd functions in a similiar way.

If your project decides to go this way i can give help with configuring if you need.