Twilight SEO

Standing at the border line. Beautiful color spectrum of Search Engine Optimization. White, Gray, Black Hat SEO learning by doing.

Lighttpd vs Nginx (Apache Benchmark)

Posted in server by ruru on the March 21st, 2009

lighttpd-vs-nginx-apache-benchmarkContinuing previous post Lighttp vs Apache2
Now, i’ve done another test Lighttpd vs Nginx using Apache Benchmark

Benchmark parameter

ab -c 300 -n 1000 …

.
.
.
.
.
Nginx + spawn-fcgi
14:31:34 up 9 days, 21:39, 2 users, load average: 18.47, 7.77, 5.68

Server Software: nginx/0.6.35

Document Path: /
Document Length: 22355 bytes

Concurrency Level: 300
Time taken for tests: 45.095 seconds
Complete requests: 1000
Failed requests: 120
(Connect: 0, Receive: 0, Length: 120, Exceptions: 0)

Write errors: 0
Non-2xx responses: 119
Total transferred: 19941669 bytes
HTML transferred: 19740333 bytes
Requests per second: 22.18 [#/sec] (mean)
Time per request: 13528.485 [ms] (mean)
Time per request: 45.095 [ms] (mean, across all concurrent requests)
Transfer rate: 431.85 [Kbytes/sec] received

Lighttpd + spawn-fcgi
14:47:53 up 9 days, 21:55, 2 users, load average: 21.21, 6.73, 4.57

Server Software: lighttpd/1.4.22

Document Path: /
Document Length: 22388 bytes

Concurrency Level: 300
Time taken for tests: 42.815 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 22599690 bytes
HTML transferred: 22388000 bytes
Requests per second: 23.36 [#/sec] (mean)
Time per request: 12844.583 [ms] (mean)
Time per request: 42.815 [ms] (mean, across all concurrent requests)
Transfer rate: 515.47 [Kbytes/sec] received

Conclusion: Lighttpd vs Nginx (Apache Benchmark)

Lighttpd gave me less error and slightly faster.

Nginx consume less resource, with slightly produce more error.
Setting low amount of worker thread will greatly reduce resource usage,
but couldn’t serve high concurrency.

Recommendation:

  • Use Nginx for Desktop based server,
  • and Lighttpd for Normal server.
  • Throw away ApacheĀ  :p

Edit:
I found the culprit that cause many errors on nginx was actually the spawn-fcgi parameters.
Nginx itself works smoothly beyond expectation.

I remark the conclusion. Both are great Apache2 replacement.

But, so far…
I coudn’t find a good numbers of childs to spawn and fork.
With nginx, it either crash my server (too high) or many failed requests (too low).

end of file … Lighttpd vs Nginx (Apache Benchmark)

Lighttpd+FastCgi+Php-Cli vs Apache2+mod_php

Posted in php4, php5, server by ruru on the March 16th, 2009

I heard a lot of good things about lighttpd and fastcgi.
People keep claiming that Lighttpd are faster than Apache2.
So here i want to prove it by myself.

If you’ve been on internet for more than 10 years,
you’ll understand that there’s a bunch of bullshit lying around.
I’m going to believe what i heard, only after i see it.

Took almost 2 days to setup the environment.
On my server, the monstrous AMD Phenom 9650 Quad Core with 4GB RAM,
coated with the best operating system in the world CentOS 5.2
(Didn’t i say there’s a bunch of bullshit on internet? You just heard one)

Okay, all set.

I install both:
Apache2 + mod_php, and Lighttpd/1.4.22 + FastCgi + Php-FCLI
Let me know if you need tutorial to put up these, i’ll post a guide by request.

Say the first configuration of Apache/2, i will name him [K]
and the second one is [L] which stands for Lighttpd.

Both [K] and [L] are on the same machine,
served on different static IP,
which you can purchase for $0.5-$3 per IP …
if you have a dedicated server.

Okay, let’s cut the crap.

I use ApacheBench, Version 2.3 as the judge.
Isn’t [L] one brave challenger here.
The situation doesn’t favor him.
I wish i can have LighttpdBench to keep the fight fair.

Oh, well i said stop the crap. Let’s go….

First round!!!!!

fight-round-1

Concurrency Level: 200
Complete requests: 1000

The result is..
Both has zero failed requests

[L] Requests per second: 67.22 [#/sec] (mean)
[K] Requests per second: 47.01 [#/sec] (mean)

WINNER: [L], FAST!
Clearly shown that [L] is 43% faster than [K]

Move to the second round!!!

fight-round-2

Concurrency Level: 400
Complete requests: 2000

[L] Failed requests: 22
[K] Failed requests: 1268

[L] Requests per second: 64.62 [#/sec] (mean)
[K] Requests per second: 87.53 [#/sec] (mean)

WINNER: [L]. HARD, STRONG, AND ROBUST.
At high concurrency level [L] has 0.0017339218158890290037831021437579% less failure than than [K]

FINAL ROUND!!!

fight-final

Concurrency Level: 100
Complete requests: 2000

[L]
Failed requests: 0
Requests per second: 65.47 [#/sec] (mean)

[K]
Failed requests: 7
Requests per second: 62.67 [#/sec] (mean)

WINNER: [L].
Given normal condition both perform almost equally,
but [L] is has less failure than [K]

Conclusion Lighttpd+FastCgi+Php-Cli vs Apache2+mod_php

[L] sitting in the corner with satisfied looks on his … her face.
Based on performance [L] beats [K] to dust
and send him fly thousand kilometer to the blue sky.
If performance is #1 int your life, then you must choose [L].

fight-winner

But remember, don’t overwhelmed with the benchmark result,
and these lovely pictures.

Benchmarking and tweaking is for poor people.
It took a lot of time just to improve the tiny bit of performance.

Take this into consideration.
Right now the majority are using Apache,
which means bunch of people swimming in this pool.

You might want to sacrifice performance,
spend less time on installation and tweaking,
and spend more money on hardware.

In the end, outcome is everything.
Means not only you have to cut hardware cost,
but also time for soft-optimization.

Later~




Cannot find your answer here?
Feel free to get in touch and ask PHP-ist anything, just anything :)