Apache vs nginx vs lighttpd (And Cherokee!)

Status
Not open for further replies.

eLight

Active Member
3,487
2011
165
0
This thread was inspired by Lifetalk in the CB, sorry but I didn't set up Cherokee as I couldn't be bothered reading up as to how. But I'll include it next time! If you want to run some tests on your own machine that'd be cool for comparison (especially with hardware and stuff).

Server specs:
CPU: Xeon X3430 @ 2.40GHz
RAM: 8GB
HDD: 2x 1000GB in SW RAID 1.
BW: 100Mbps (Not that it matters...).

Server is CentOS 64bit, completely fresh format and the latest available kernel. Nothing has been ran on this server previously. There's no optimizations made server side, as this is to give a comparison of the http servers only. PHP 5.3.6 is used for all tests.

Apache is the "every mans" httpd. It is pretty good for hosting, very good at handling host names and what not, but it's kinda sucky for performance. That's not to say that it can't be configured well. But, to give a comparison to lighttpd and nginx, I've left Apache as is with a standard PHP CLI installation. Both nginx and lighttpd are very, very easy to install and configure with php-cgi. I've ran tests without any cache op as well as xCache and APC. Minimal configuration options are used besides the bare requirements for them to operate.

A concurrency of 10 is used for all tests, a total of 20,000 requests is made. Reading around the net you'll usually see recommendations such as "nginx for static" ... "lighttpd for php-cgi" for example, so, let's see if all these peoples thoughts are true :)

Static Files

WJ's logo.png

Apache:

Requests per second: 6309.83 [#/sec] (mean)
Time per request: 1.585 [ms] (mean)
Time per request: 0.158 [ms] (mean, across all concurrent requests)

lighttp:
Requests per second: 10981.46 [#/sec] (mean)
Time per request: 0.911 [ms] (mean)
Time per request: 0.091 [ms] (mean, across all concurrent requests)

nginx:
Requests per second: 11286.66 [#/sec] (mean)
Time per request: 0.886 [ms] (mean)
Time per request: 0.089 [ms] (mean, across all concurrent requests)

Winner: nginx

PHP file no xCache/APC

A PHP file with the following code is used. Nothing complex, just a simple piece of code that will out put "Hello!" 5 times.

PHP:
<?php
$arr = array(1, 2, 3, 4, 5);
foreach ($arr as $val) {
echo "Hello!";
}
exit;
?>
Apache:
Requests per second: 3495.35 [#/sec] (mean)
Time per request: 2.767 [ms] (mean)
Time per request: 0.277 [ms] (mean, across all concurrent requests)

nginx:
Requests per second: 3942.56 [#/sec] (mean)
Time per request: 2.536 [ms] (mean)
Time per request: 0.254 [ms] (mean, across all concurrent requests)

lighttpd:
Requests per second: 4091.25 [#/sec] (mean)
Time per request: 2.386 [ms] (mean)
Time per request: 0.239 [ms] (mean, across all concurrent requests)



Winner:
lighttpd

With xCache:

Please note Apache is skipped for this test.

nginx:
Requests per second: 4118.34 [#/sec] (mean)
Time per request: 2.428 [ms] (mean)
Time per request: 0.243 [ms] (mean, across all concurrent requests)

lighttpd:
Requests per second: 4596.48 [#/sec] (mean)
Time per request:
2.176 [ms] (mean)
Time per request:
0.218 [ms] (mean, across all concurrent requests)


With APC:

nginx:
Requests per second: 4075.07 [#/sec] (mean)
Time per request: 2.454 [ms] (mean)
Time per request: 0.245 [ms] (mean, across all concurrent requests)

lighttpd:
Requests per second: 4166.00 [#/sec] (mean)
Time per request: 2.400 [ms] (mean)
Time per request: 0.240 [ms] (mean, across all concurrent requests)


Winner: May as well be a tie. Except lighttpd does perform better with it's "native" xCache, which I guess can be expected considering it's made by the same people.

Take this as you may. I am unbiased between nginx or lighttpd. I've used both and they both have their pro's and con's. Overall I think nginx is a better performer for proxy setups and static files whilst PHP just takes the cake for PHP. I guess this simple test proves that in a way. But either way, if you set up your server correctly you won't notice much difference between them. I definitely recommend them over Apache.

Another thing to bear in mind is that these results may differ highly to your own server, this server is a completely stock standard machine and there's many things you can do to increase the performance!

Cherokee vs Apache vs lighttpd vs nginx (Static only).

Thanks to Lifetalk!

His vacant box:
CPU x3440 @ 2.53GHz
8GB Memory
2x1TB Drives in LVM (consider this equal to SW RAID 0)
BW: 1gbps, not that it matters.
Tested file: WJ logo

APACHE:
Requests per second: 10820.39 [#/sec] (mean)
Time per request: 0.924 [ms] (mean)
Time per request: 0.092 [ms] (mean, across all concurrent requests)

CHEROKEE:
Requests per second: 12190.83 [#/sec] (mean)
Time per request: 0.820 [ms] (mean)
Time per request: 0.082 [ms] (mean, across all concurrent requests)

NGINX:
Requests per second: 14842.53 [#/sec] (mean)
Time per request: 0.674 [ms] (mean)
Time per request: 0.067 [ms] (mean, across all concurrent requests)

LIGHTY:
Requests per second: 13922.32 [#/sec] (mean)
Time per request: 0.718 [ms] (mean)
Time per request: 0.072 [ms] (mean, across all concurrent requests)
 
35 comments
i love this review of the three web servers eLight, i my self use nGinx with apache it works very well i would recommend nGinx to anyone i my self have been meaning to try out lighttpd never have used it.
 
Well, lighttpd and nginx can be used together. A bit more to set it up, but the results would be there if you're struggling for performance!
 
can you add litespeed standard edition in the comparison aswell please?

and if possible also add memory used by each webserver
 
I've used litespeed once, two years ago maybe, both nginx and lighttpd out performed it. That may have changed but in my eyes these are better and free.
 
^^ according to litespeed staff LSWS is far better than nginx, so i just wanted to see that in action :P

Code:
http://www.litespeedtech.com/support/forum/showthread.php?t=2429
 
About an hour or so. I already had some of the stuff installed, was just the screwing around, installing the accelerators and editing that was annoying :P
 
Well I don't have benchmarks, but I can give you first hand at the use of LiteSpeed.

I was looking for something to more less 'Prevent DDoS Attacks' as 'Apache 2.2.x' wasn't working for my hosting web server and since I use cPanel, I had to find a solution. I've knew about LiteSpeed and figure I'll use a 'Free Trial' and see how it works.

Even though there trial only goes for 15 days (You can get two trials for the same server IP and use it for one month) afterwards, I bought a 1 CPU at $32.00 (Don't need all cores to be bought) - This does more less prevent DDoS, but I've noticed a lot my clients complaining in regards too sites not working, Such as Ajax based chat clients or settings were not in an admin control panel were not working, not to mention the /tmp really got full and cause the LiteSpeed server to die constantly.

After messing with this for 3 months after constant tweaking, I found I was it was causing me to loose customers.

I needed a completely different solution, I was wondering if Nginx was even supported with cPanel, one day I was installing FFMPEG for a VPS client and I noticed something on the corner of my eye cPNginx - The creators of ffmpegautoinstall also has an cPanel Nginix, So I was like what the hell.

Switched back to Apache.
Disabled LiteSpeed Completely.
Installed Nginx and used there Free Trial.

I have to say, The performance is so much better and runs side by side with apache and none of my clients are complaining, not to mention this also more less prevents DDoS.

So I paid the $5 per Month and I use this on two of my servers and may consider paying a year in advance.
 
^^ according to litespeed staff LSWS is far better than nginx, so i just wanted to see that in action :P

Code:
http://www.litespeedtech.com/support/forum/showthread.php?t=2429

Lol Litespeed Staff. They're staff; they'd say anything and everything without much basis to it if it helped them sell their product.
 
I agree with eLight totally when it comes to lsws (Litespeed web server)

nGinx owned Litespeed when i ran my bench marks last year i think i have also had talks with Lifetalk months ago about how crappy litespeed was compared to nGinx ?
 
I'd personally always stay away from a paid webserver software. Nginx (did you guys know it was initially meant to be called EngineX ?) outperforms LSWS; all the time. There's no reason to pay for a webserver if a free alternative performs better. Only reason I see is that it has a few performance gains over Apache, and allows you to retain Apache's .htaccess mod_rewrite syntax.

Oh and Cherokee does not have rewrite support in the traditional way. You can't just define rewrite rules in some file. There's a sophisticated way of doing them, although once you get used to them - they're pretty easy.
 
i get better stats with lighttpd then with nginx on my site/server. but maybe that this is because i have most PHP and not total static (cached html) pages.

+ less errors, but nginx will fix the errors too in the future i think, it's still new. i'm mean new compared to apache and lighttpd. but it's not that new in days/years. :>
 
I've always pronounced it "en jinx". Though I do remember reading somewhere that it's meant to be pronounced engineX.

So do I, even though its not correct, I think most people do.

N-gin-X is how its meant to be though.

i get better stats with lighttpd then with nginx on my site/server. but maybe that this is because i have most PHP and not total static (cached html) pages.

That shouldn't matter. Both nginx and lighttpd proxy to a 3rd party php interpreter like fpm to handle php, so technically that shouldn't make a difference.

I'd personally go with nginx, but thats because its actively developed and they have very helpful/knowledgeable support staff.
 
Status
Not open for further replies.
Back
Top