New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
@marcm: exactly! Completely agree with you!
Me.
Seeing as I only changed the HTTPd and not the underlying software, and CPU usage magically went down, I can only conclude that it was Apache and not PHP causing the CPU spikes.
I always find this a bit of an odd argument. If you need to spend a significant amount of time and have a significant knowledge of a HTTPd to be able to configure it in a way that it actually works properly, then why would you use it if another HTTPd offers this out of the box with no configuration required?
Well I know that at Mashable (where I work as a reporter, not admin, but I'm one of the few that can get excited and need out with our CTO), when we moved from Apache to Nginx, it cut down our overhead and page load like a mofo. And that was back when we were on WordPress on the frontend (now we're on Ruby, Mongo and lots of JavaScript) and needed some ridiculous number of servers and instances just for database.
It doesn't shock me that the bigger sites are switching because if you're serving millions of visitors a day - and often 10,000+ concurrent visitors -- and that's for a dynamic news site, not a web app -- Apache just doesn't work as well.
I'm not sure how nginx's defaults are configured, but the Apache ones aren't set for LowEnd by default. So it's only natural you have to tweak it a bit to get better performance. So while I don't disagree with you that Apache doesn't server LowEnd well out of the box, I also don't agree what you need to spend a significant amount of time and have significant knowledge to tweak a number of Apache parameters.
Besides, most people (and most guides) still use the old Apache Prefork server, which is considerably slower than the MPM Worker or the 2.4 Event-driven worker (which matches/is faster as nginx), especially when used with PHP.
Anyway, here's an interesting read about Apache 2.4 and some of the discussion about it's performance: http://apache.slashdot.org/story/12/02/21/1632230/apache-24-takes-direct-aim-at-nginx
@mpkossen in all fairness I have to say that Nginx is easier to learn than Apache. I find it weird that some people think the opposite.
The configuration for Nginx is definately easier to learn and use. I would also say performance is better, but I've seen cases where Apache wins.
I'm all lost in nginx configuration. We have two load balancers here at the office running nginx. Always takes me longer to fix things than with Apache (with which I just know what to do). My point being: it boils down to experience configuration-wise.
Could you please share any tutorial or tutorial links to best optimize Apache 2.4 for low end boxes?
Haven't got any links for you, sorry. It is on my list for a LEB tutorial, though. I haven't yet had to optimize Apache yet (as in: most of my servers are big enough to handle the load they get just fine). All my servers also still use Apache 2.2, as that's the one that shipped with Ubuntu 12.04 LTS, so I haven't got much hands-on experience with 2.4 yet except some tests.
By the way (edit): the default Apache 2.2 config with the MPM Worker (on Ubuntu) results in a memory usage of at most 6MB reserved per apache process (in my case 4 in total). PHP-FPM, however, is the real memory hog with 3 processes needing 17MB each.
I'd like to get back on this. I've now got two boxes up and running, one with Apache and one with NGINX. Both have:
php5-fpm (tweaked configuration, identical)
postgresql (default configuration, identical)
I've tweaked the default Apache config just a bit (because the default config is not fit for low-end boxes):
I've compared the memory usage of Apache and NGINX in an idle state:
This is just a very basic and preliminary result. I've still got to do ab runs against both servers. But I wanted to share this anyhow.
Results from an Apache Bench to a phpinfo() file.
NGINX machine to Apache machine:
Apache machine to NGINX machine:
@mpkossen So you ignore the main strength of nginx?
Try -c 50 or -c 100 if you want to see the real strength of each web server.
You can seat Varnish in front Ngnix to drive the performance through the roof. Varnish is great at caching dynamic content. It would serve PHP files as though they were static output.
Would love to see a decent tuning guide for apache and nginx, comparing their strengths and weaknesses as well as a few benchmarks... Aimed at 128/256 Mb RAM nodes would be awesome.
... Anybody in the know with this?
I'm an NGINX noob (basically, I have worked with it, but don't know much about it) so I honestly don't know where it's strengths are. I'm going to run the ABs again with higher concurrency, see what that does :-)
@BluBoy: it is on my list for LEB, but these things generally take up a lot of time, so I can't promise it's be finished next week or something like that. More like a month.
Apache:
NGINX
mpkossen@postexus:~$ ab -n 1000 -c 50 http://postexus2.example.net/info.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
I can just say: wow! I'm impressed! Never knew it made that much difference.
I'm curious how this will work with Apache's event worker. I'm trying to set that up now but apt is a bit grumpy this morning.
EDIT: nope, event-worker on 2.2 did nothing. Still the same.
Yes! But I still want to know the difference between NGINX's event model versus Apache's worker model. NGINX doesn't do the keepalive and I want to know what effect that has.
Nginx sacrifices a little speed with creating a new connection, Apache sacrifices a lot of speed by being all bloated in the core.