Nginx as reverse proxy + Apache or Nginx Stanalone

Hello,

We are in process of changing the server stack and considering using Nginx.

Question is should we run Apache plus Nginx as reverse proxy or just run Nginx replacing Apache completely? Which will give better performance specifically for Elgg. We are still using Elgg 1.8.x

Can anyone share the experiences or tips on best way to utilize Nginx?

I know community here runs on Nginx and from many discussions there are many community members using Nginx with Elgg.

Any thoughts on this are greatly appreciated.

Thanks.

  • From my experience while benchmarking, apache prefork tends to become unstable for concurrencies above 256 as well as tends to starve 2-3% of the requests under heavy load. It won't even crash on it's own, but I needed to eventually kill it manually. Since than I don't use apache unless I have to.

    Apart from that nginx is slightly better at serving static content.

    Having apache as a nginx backend pretty much defeats the purpose unless you just want it to ast as a load balancer.

    Simplest way I'd recommend is to install php5-fpm and nginx and configure it to use php via fastcgi. Simple, but fully working config that you can modify, is here: https://gist.github.com/Srokap/7dbfc423812f09a5ee43

  • @srokap

    Thank you so much for sharing your experiences and the nginx config:)

    I do have test server running just Nginx/MariaDB, setup using Centminmod script and seems to work pretty good in testing environment.

    I was just curious if it is better to use combo Apache/Nginx reverse proxy or just Nginx. We are in process of moving database to separate instance to help with the load so really trying to do anything that is possible to scale Elgg.

    Our biggest issue I think will be data folder and files as our members are constantly uploading files and large files. I'm still looking for best solution to offload data folder somewhere else. We thought about using Amazon but from discussions found here on community it seems like it's not that simple and requires core hacking.

    Is there a viable solution for offloading data folder away from the app server?

    We will be staying with Elgg 1.8 for a while because of too many customized plugins.

    Thank you.

     

  • @This Script Lover

    Our biggest issue I think will be data folder and files as our members are constantly uploading files and large files. I'm still looking for best solution to offload data folder somewhere else. We thought about using Amazon but from discussions found here on community it seems like it's not that simple and requires core hacking.

    Is there a viable solution for offloading data folder away from the app server?

    We use NFS mounts to offload the data folder to a different server/san. There are probably other ways to mount network shares, pick one and try it.

    No core hacks required ;), just configure the dataroot path to the network mount

  • @This Script Lover Some tutorials with my 2 cents ;)

     

    NGINX StandAlone Installation & Configuration

    //installations

    • apt-get install mysql-server mysql-client
    • apt-get install nginx
    • apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
    • apt-get install php5-fpm
    • apt-get install php5-apc

    //configs

    nginx.config

    site-available

     

    Apache + Nginx

    Read this manual

     

    Some tips for Elgg Performance & Scalability

    Additional useful topics on community

  • Wow what a great response, thank you guys for your input and references :)

    So it seems the best is to use standalone Nginx, separate instances for database and data/files folder (assuming we can successfully connect Elgg to database instance and data instance).

    We are using Digital Ocean so it should be not too much trouble connecting instances using private IPs as they will be on the same network.

    @Jerome Bakker, Is that how NFS mounts are connected? using server instance IP  for data folder? So dataroot would become for example http://199.236.77.99/var/www/mydatafolder  ? instead of /var/www/mydatafolder ?

    @RvR, is your Nginx .conf you linked to for Elgg 1.8 ?

    Thanks.

  • @This Script Lover

    is your Nginx .conf you linked to for Elgg 1.8 ?

    Yes

  • @This Script Lover

    Is that how NFS mounts are connected? using server instance IP  for data folder? So dataroot would become for example http://199.236.77.99/var/www/mydatafolder  ? instead of /var/www/mydatafolder ?

    I don't know excactly have NFS mounts work, i'm not a server admin ;)

    but is more like /var/www/mydatafolder is a symbolic link to <some server address>/<some path>

  • Awesome!

    Thank you all, that should get me started :)

    If anyone else has experiences/recommendations with Nginx please do add it here.

     

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.