4 ms·
+1 for NGINX + PHP-FPM + XCache + MySQL as a replacement for the LAMP stack - significantly decreased my web server's utilization of both CPU and Memory...
by kitcar 17y ago
+1 for NGINX + PHP-FPM + XCache + MySQL as a replacement for the LAMP stack - significantly decreased my web server's utilization of both CPU and Memory...
- paraschopra 17y agoCan you detail this configuration? How easy/hard is it to setup this stack and then later maintain it? Plus, how much improvement did you actually get will be an interesting piece of info.
- chrischen 17y agoIt's gotten a lot easier recently. I believe I installed PHP-FPM through aptitude, and nginx comes from that too. Compiling a newer version yourself isn't that hard. However maybe 2 months ago I couldn't say the same. EDIT: I had to add dotdeb repo for php-fpm.
- paraschopra 17y agoYup, researched more and found this excellent Linode article http://library.linode.com/web-servers/nginx/php-fastcgi-ubuntu9.10-karmic http://library.linode.com/web-servers/nginx/php-fastcgi-ubun... Also, unrelated, but I see most arguments in favor of nginx say that it is excellent at serving _static_ files. Since my application serves mostly dynamic content, what do you think can be performance benefits? EDIT: This article is fantastic too http://interfacelab.com/nginx-php-fpm-apc-awesome/ http://interfacelab.com/nginx-php-fpm-apc-awesome/
- chrischen 17y agoWell if you don't run your app as CGI then there might be a difference. For example using mod_php vs fastcgi or fpm (from what I hear mod_php is faster than fastcgi). And if you host your static files on a CDN that's even less reason to use nginx. Here's some benchmarks: http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/ http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-ngi... It shows that if you just run PHP, mod_php results in better performance. So, many people who also need to serve static content use nginx for static, and then proxy PHP requests to apache (though this seems like it would defeat the purpose of needing apache). Of course this all becomes moot if you consider that when you get to these points of performance demand you'll probably take a look at HipHop (assuming you use PHP) and compile your PHP+Web server into a single daemon. EDIT: By the way, that linode article uses spawn-fcgi, not php-fpm. php-fpm is in the dotdeb repository and you have to add that to your sources.list.
- stanley 17y agofrom what I hear mod_php is faster than fastcgi Those benchmarks certainly back it up. Nginx in front of Apache seems like the best approach. I would like to see an optimization guide for setting up Apache to process PHP via mod_php. By comparison, I always found optimizing nginx to be far more straightforward than optimizing Apache. On a sidenote, does it make sense to use HipHop in conjunction with xcache? Here's what I'm thinking: nginx > static files nginx > php > apache + mod_php > xcache > HipHop
- wizard_2 17y agoHipHop will completely invalidate your need for Xcache as you now have an executable instead of php. You can probably get away with nginx for static and proxy it to HipHop'd php for your php. But that's still overkill in most situations. The nginx for static and php-fpm (which runs php as a fcgi) will get you very very far. Wordpress.com for example uses a similar setup (with a hell of a lot of caching in between). Most of my apps aren't bound by php cpu time, I'd only use hiphop to play with personally. =)
- easp 17y agoProxying to Apache for dynamic requests is still a win if you let nginx buffer the response. This local transfer is fast, which frees the apache process, and all the memory it uses, to serve the next dynamic request while nginix takes care of emptying the buffered data to the "slow" client. At the same time, you get to tap the vast knowlwge base for deploying php apps on apache.
- jawngee 17y agoThanks, I wrote the interfacelab article. We (at the time I was the CTO for massify.com) evaluated a lot of different configurations and nginx+php-fpm+apc was about the fastest we could get the site going. Glad the article was useful for you.
- kitcar 17y agoon the maintenance side - I find NGINX conf files to be substantially easier to work with than Apache's - check out the demo conf at the end of this article for example: http://www.linuxjournal.com/article/10108 http://www.linuxjournal.com/article/10108 . And setup was pretty easy, as most components are available from the package manner of your choice - http://www.newmediaist.com/n/installing-nginx-mysql-php-fpm-xcache-centos-53-howto http://www.newmediaist.com/n/installing-nginx-mysql-php-fpm-...