5

Any of these web server software i.e., Apache, Nginx and Cherokee is suitable for my website at the moment. And I am learning sysadmin to be able to manage my server (and not for a job).

For a beginner that I am, any web server is equally new. So, please take a look at my requirements and kindly suggest a web server software to start with (and sit on... like forever):

  • Scalability
  • low resource footprint
  • support for PHP, MySQL, APC, Memcached, Meteor - - all for a wordpress website
  • useful now and in the long-term as my website's traffic increases
  • load tolerant
  • everything else...

As you can see, I am still in the beginner's phase. So, please don't come saying this is a controversial question. It definitely abides by SF's rules (or hopefully so, I just read them).

5 Answers5

11

Apache sure is your safest starting point. Not that it's necessarily easier than the others, but the software you want to run on top of it has been tested with Apache with 100% certainty. Usually everything works with other web servers too, but unless you already have experience about typical gotchas, Apache is the way to go for you.

Performance-wise Apache is fine. nginx, lighttpd and other more performant web servers starts to matter only in corner-cases like YouTube. For your typical web sites (where with a decent server & network bandwidth 'typical' can easily be tens of millions of page loads per month) Apache won't be the bottleneck; it can handle thousands and thousands of static http requests per second without sweat, and with dynamic applications your PHP script / database / whatever is the actual bottleneck, anyway.

If Apache starts to be your bottleneck, you most likely need to scale out with more hardware. Though one scenario where nginx & lighttpd truly shines is serving out lots of large static content, such as video files.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • I am looking at a 50 million pageview (per month) bearing website. Is Apache still fine? –  Aug 10 '11 at 09:13
  • It depends on your application and your server environment. Want to be sure? Benchmark! Shoot your server with Apache Benchmark, Siege, JMeter or some other benchmarking tool and see if it can handle that kind of traffic. – Janne Pikkarainen Aug 10 '11 at 09:17
  • 7
    50M page view/month is 19 per second - apache will barely notice this. – user9517 Aug 10 '11 at 09:19
  • @Iain so, under this kind of load, Apache is as good as Nginx or Cherokee, right? –  Aug 10 '11 at 09:20
  • @Aahan: Like I mentioned earlier, Apache can easily serve thousands of http requests per second with static content, with dynamic content the bottleneck will be your web application, not Apache. – Janne Pikkarainen Aug 10 '11 at 09:48
  • @Janne Pikkarainen you are very right, but now I am thinking about resource usage. My question now is, `Is Apache as good as (or at least comparable to) Nginx/Lighttpd/Cherokee etc in terms of resource usage under a load like 30 pageviews per second?` I also realized that Apache is the best dynamic content server around. –  Aug 10 '11 at 09:52
  • 5
    @Aahan: 30 pageviews per second is like background noise to whatever webserver you choose. Your server will barely notice that and with any decent server hardware the load average should hover near zero. – Janne Pikkarainen Aug 10 '11 at 09:55
  • @Janne Pikkarainen One last question. when using a content delivery network like Amazon CloudFront or EdgeCast, do I still have to use software like Varnish? Thanks. –  Aug 10 '11 at 10:02
  • @Aahan: If you _have_ to use software like Varnish in addition to CDN, then you're traffic levels are already way more higher than 50 million pageviews and you will have several other challenges waiting for you. :-) And since you said 'Wordpress', it's worth mentioning that W3TC WordPress cache plugin has support for Amazon CloudFront, at least. – Janne Pikkarainen Aug 10 '11 at 10:16
  • @Janne Pikkarainen `(1)` So in short, a blog getting 50 million pageviews (or 20-30 pageviews per second) will have little to no difference when using Varnish in addition to a CDN, right? So, a CDN should be sufficient. `(2)` This is my idea: CentOS > Apache (PHP, MySQL) > APC, Meteor (for live blogging) > Wordpress with W3TC + CDN. Good? –  Aug 10 '11 at 10:24
  • 19 req/s against Apache2 doing static files is nothing. 19 req/s against Apache2 doing mod_php against a large PHP script is pain.. – pauska Aug 10 '11 at 13:56
  • @pauska: 19 dynamic requests per sec with Apache and mod_php pain? Wow, you either have a very slow server or very heavy scripts to run. – Janne Pikkarainen Aug 10 '11 at 14:02
  • @JannePikkarainen you have clearly never worked for a nonprofit where servers span 6 Pentium generations. the budget'll be there next year, but it works now... sure ;) – Michael Lowman Aug 10 '11 at 14:07
  • When I started our only server was an IBM NetFinity server with Pentium 3 Xeon and 1 GB RAM hosting stuff for around 50 000 customers. We also had PHP support. Yes, this was back in 2001 and there were not that many PHP users but still, yes, I know the pains and gains of PHP. I also know how poorly coded CakePHP based application can bring 8 core server with 16 GB RAM to its knees. – Janne Pikkarainen Aug 10 '11 at 14:17
  • 2
    There's actually a huge increase in server performance going from Apache to Nginx when mod_php is involved. Apache does not distinguish between processes with and PHP embedded so a simple image request can keep PHP busy (although usually for a short time) Nginx avoids this issue by separating the two out. I'd highly recommend getting a spoon feeding layer for Apache at the very least. – Martin Fjordvald Aug 10 '11 at 14:21
  • 1
    @Martin F: Yes, this kind of things start to matter with serious traffic. One common way even with apache is to separate the static content to its own subdomain, such as images.yourdomain.com or static.yourdomain.com and have another server / Apache instance responding there, and having another server or more for dynamic content in www.yourdomain.com or yourdomain.com. Certainly there are dozens of other ways to accomplish this. – Janne Pikkarainen Aug 10 '11 at 14:30
4

I think Apache is the one with most tutorials and people that can help. Plus the combination (L)AMP - Linux Apache Mysql PHP works right from the start and is very easy to set up. Memcached also works fine with Apache and your mySQL database, if your site needs to scale to an intermediate size. I started with a simple LAMP setup and later installed Memcached when the traffic increased to several sites. With the help of some tutorials, everything was quite straightforward.

Claude
  • 66
  • 4
  • But I also heard Apache isn't very load tolerant, and aside from that it is also high on resources, isn't it? –  Aug 10 '11 at 08:57
  • Compared to resource consumption caused by typical PHP stuff (WordPress, Drupal....) the Apache resource consumption is child's play. – Janne Pikkarainen Aug 10 '11 at 09:18
  • Memcached and MySQL have nothing to do with Apache.. You can use them with any web server, or without one. – Brendan Long Aug 10 '11 at 15:54
  • I fully agree with you, Memcached can be used with a variety of web servers and databases. But especially for beginners it is best if there are a lot of tutorials with the same setup... at least that helped me a lot. – Claude Aug 10 '11 at 16:29
  • @Claude - But using Memcached is entirely based on the language. It never talks directly to the web server.. – Brendan Long Aug 10 '11 at 19:01
3

Apache is probably a safe bet for almost any "beginner's" scenario, mostly because of the vast expanse of documentation available for it.

NGINX is a great web server (among other things), but trying to integrate PHP and/or CGI with it requires some effort and hackery. It is very lightweight, and can do a lot of fancy stuff (like reverse-proxying), but it's probably not the best thing to bootstrap yourself on.

gWaldo
  • 11,887
  • 8
  • 41
  • 68
2

You're asking for the moon on a stick..

Apache a is very modular, easy to configure and updated web/application server. It is however not great for handling high volume traffic when doing application processing (like PHP), as it eats away enormous amounts of RAM for each children.

Nginx is a great webserver. It requires little to no resources (I've heard about production sites using 25MB ram and 2-3% CPU). It is however not an application server at all. It serves static content, or it proxies. Nothing else.

I've used both for a long, long time. Nginx+PHP-FPM is fun to set up and tweak, but often not necessary.

pauska
  • 19,532
  • 4
  • 55
  • 75
  • 1
    Just to clarify though, nginx does have native server-side includes, and supports FastCGI, so it is not purely proxy-or-nothing. It can also be set up to serve static content, pass anything it could not serve onto annother server, and replace any 404 or similar errors with a server-side redirection. – Kevin Cathcart Aug 10 '11 at 20:22
  • @Kevin Cathcart: I think you misread my answer, I wrote "It serves static content, or it proxies. Nothing else." as in "does not parse any dynamic language" – pauska Aug 13 '11 at 10:10
  • 2
    I was not misreading your answer, but I saw that it could be misread, so commented to clarify. Server side includes is not included in many people's defintions of static, depite not really being dynamic either. It would also be easy to misinterpert "or it proxies", as requiring a fully compliant HTTP 1.1 server to host the dynamic content, which is not the case, since it can also proxy to FastCGI services. Since those misreadings were possible, I thought clarifying them in a comment may be worthwhile. – Kevin Cathcart Aug 16 '11 at 15:59
1

I've played with cherokee and apache2 both of them are nice and well documented. Cherokee does future a GUI webinterface to manage your server, which might be easier for some people. Especially beginners.

However most of the time when I need to get up a webserver quickly I resort to apache2, just because I'm used to setting it up.

When choosing between these three, you cannot go wrong with any one of them. All of them are good and have their pro's and con's, I suggest you take a look at some benchmarks like this one.

Lucas Kauffman
  • 16,818
  • 9
  • 57
  • 92