Hacker News new | ask | show | jobs
by czervik 5269 days ago
Isn't nginx more often than not used as a front controller for apache/tomcat/etc?
2 comments

Earlier, nginx was used to handle just static content and passed the php stuff to apache httpd. These days people just use php-fpm instead so nginx can handle everything in a php based stack without needing apache.
Is this faster or the same speed? There is so much FUD around this topic that I've not been able to get through.
Using mod_php with Apache IS faster than PHP-FPM, however, it uses MUCH more RAM. In a RAM constrained environment like a VPS, it simply isn't an option.
The latter part is simply not true - I run Apache with mod_php for a number of sites and web services on VPS's with little RAM without any problems, and that's alongside MySQL, Exim and SpamAssassin.
What's the traffic though?
I don't have exact figures, but each site probably gets a few hundred hits/day, and the mail server probably gets hit every few seconds. The OP made a sweeping "not an option" statement though, not "on a popular site hosted on a VPS".
Nginx + php-fpm is MUCH faster than a vanilla apache httpd + php stack. The magic though, is not just speed. It's also the feature-set. I'm working on a pyramid(pylons) project right now and will be using nginx to load-balance the wsgi server instances and to serve static content. I don't think I could use apache for that. The configuration for nginx looks neater as well (my personal opinion)
Are you sure about that?

Benchmarks on my projects show that the difference is insignificant. Since I currently do not have memory constraints I am still using nginx + apache with mod_php.

I remembered the benchmarks as being well in nginx's favour but it seems I was mistaken. As maratd has noted above, apache with mod_php is faster.

But like I said, nginx is great for doing loads of things and I sort of "quit php" recently so I don't really care about php performance anyway.

It can be used like that, however I am not sure if that's the most implemented method.

Personally I use Nginx > PHP-FPM, so there is no other web server on the box.