tentimes wrote:
I was put off Apache after looking at how it handles lots of requests, as opposed to nginx, which seems to offer much better CPU and load.
I got myself into a similar mental state when doing my first Linode, particularly after reviewing the forums here which can often come across (particularly a year+ back) as "apache evil, other stuff good" upon first glance. As with most things, it's not quite that black and white. But at the time I got scared away from using Apache and tested lightppd and nginx (which I had to build locally to get a recent enough version) and settled on nginx.
Now I was mostly static, or proxying to my own application server, but then on one of my servers I needed to support cgi, so I ended up installing Apache anyway just to let nginx forward the occasional cgi request to it. I've also got a CMS now I'm testing that has various custom stuff provided as an Apache .htaccess so I need to use Apache or manually convert that into nginx compatible configurations.
Quote:
So, if anyone would like to share their thoughts here I would be very grateful to hear it

Feel free to flame me, as I know in the end it's my lack of skill that is probably at the root of it

EDIT: I should add that I think the reason it's like a losing battle is that nothing is optimized to work with nginx and everything works well with apache.
If I were doing it all over again, and I had applications for which an Apache configuration was quickier/easier (even if just for me) or more standardized, I'd just start with Apache, and only worry about other options if performance became an issue. That may be a minority position in these forums, but over time I've done some of my own configuration testing and benchmarking, and the gap between a well-tuned Apache configuration and nginx is nowhere near as large as it is sometimes made out to be. Also, I pretty much know Apache will have every knob and bell I might need, plus I know I can always add nginx in front of it if needed later.
In terms of the core issue - Apache default configurations on many distributions are set to permit the use of lots of memory (by allowing many client processes, each of which can be fairly large especially when using the prefork mpm while embedding interpreters like php with mod_php). And using up all your memory, causing swapping, is a sure fire way to kill your Linode's performance.
Conversely, a default nginx setup tends to have a smaller working set, not to mention forcing you to immediately deal with offloading php to a separate process since it has no equivalent to mod_php. But that same offloading can be done with Apache too.
And some basic Apache tuning can very quickly even the playing field. First, make sure that your peak client count will fit in memory, since swapping will kill you. Then see if it that configuration can handle your load.
If not, a next step can be to offload php to a separate process (ala fcgi) so you can let Apache handle static requests with fewer resources, and manage your php resources independently. Or, you can consider fronting apache with nginx for static resources and only using Apache for php.
But I'm convinced that for the vast majority of purposes, Apache is just fine once tuned slightly, and it's certainly the case that various packages integrate more cleanly with Apache or at least have better documentation on doing so. They might also include .htaccess files to drop into Apache while you'll have to convert them for nginx use.
That's not to say that ngnix (or lightppd) or other alternatives are bad. I still use nginx on many of my nodes, and it's an absolutely excellent server. Yes it can have a smaller memory footprint than Apache, and while my own testing places them pretty close, under static loads I wouldn't be surprised if its raw rps limit is higher than Apache. But it's also something you can evolve to when needed.
Life's complicated enough when just getting going with a VPS - if you have an easier time getting your particular application stack working with Apache, I say start with that and then tune as needed. Just be sure to check your distribution's default configuration to be sure that you don't start off thinking you're fine only to have it die under the first heavy request load (which is what I think happens to a lot of people unexpectedly, and ends up turning them off of Apache). So once you're up, stress your node with 'ab' with enough parallel requests to be sure your working set is appropriate, and only then judge what further tuning you may need.
-- David