nginx vs Tornado Web vs Apache Performance Benchmark

Let’s put the nginx, Tornado and Apache and see who is the winner.

What to test:

A simple Hello World webpage.

How:

ab -n 10000 -c 300 http://myserver.ip

Test Environment:

OS: Ubuntu 9.10 (32-bit) / Linux 2.6.31
CPU: Pentium Celeron M 1.5 GHz
Ram: 512 MB
Apache: 2.2.12
PHP: 5.2.10
Python: 2.6
Tornado: 0.2
nginx: 0.6.13

Result:

Apache

Server Software:        Apache/2.2.12
Server Port:            80

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      300
Time taken for tests:   5.295 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2863146 bytes
HTML transferred:       130143 bytes
Requests per second:    1888.58 [#/sec] (mean)
Time per request:       158.850 [ms] (mean)
Time per request:       0.529 [ms] (mean, across all concurrent requests)
Transfer rate:          528.05 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    8 151.0      0    3028
Processing:     0  122 602.0     48    5289
Waiting:        0  122 600.8     48    5284
Total:         10  130 622.1     49    5292

Percentage of the requests served within a certain time (ms)
  50%     49
  66%     50
  75%     50
  80%     51
  90%     53
  95%     63
  98%     68
  99%   5271
 100%   5292 (longest request)

nginx

Server Software:        nginx/0.6.13
Server Port:            8000

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      300
Time taken for tests:   3.172 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2230000 bytes
HTML transferred:       130000 bytes
Requests per second:    3152.12 [#/sec] (mean)
Time per request:       95.174 [ms] (mean)
Time per request:       0.317 [ms] (mean, across all concurrent requests)
Transfer rate:          686.45 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2  68.3      0    3057
Processing:     0   70 359.1     27    3164
Waiting:        0   70 359.1     26    3164
Total:         10   72 365.6     27    3169

Percentage of the requests served within a certain time (ms)
  50%     27
  66%     27
  75%     27
  80%     27
  90%     28
  95%     29
  98%     32
  99%   3157
 100%   3169 (longest request)

Tornado Web:

Server Software:        TornadoServer/0.1
Server Port:            8888

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      300
Time taken for tests:   5.109 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1680000 bytes
HTML transferred:       120000 bytes
Requests per second:    1957.33 [#/sec] (mean)
Time per request:       153.270 [ms] (mean)
Time per request:       0.511 [ms] (mean, across all concurrent requests)
Transfer rate:          321.12 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   32 309.3      0    3035
Processing:    33  103  28.5    103     375
Waiting:       33  102  28.5    103     375
Total:         36  135 311.3    103    3154

Percentage of the requests served within a certain time (ms)
  50%    103
  66%    105
  75%    108
  80%    112
  90%    116
  95%    126
  98%    313
  99%   3121
 100%   3154 (longest request)

What do these numbers mean?

In a given time, if nginx and Tornado Web can handle 1.66 and 1.036 times more requests than Apache, respectively! In the other words, the server is more efficient and it can use the saved resource to do something else!

–Derrick

Our sponsors:

Tornado Web Server – Very Fast!

I just did a benchmark comparison on Tornado Web Server and Apache + PHP server. The result is pretty amazing.

What to test:

A simple Hello World application.

How:

ab -n 1000 -c 300 http://myserver.ip

Test Environment

OS: FreeBSD 7.1
CPU: Pentium III 933 MHz
Ram: 256 MB
PHP: 5.2.9
Python: 2.5.4
Tornado: 0.2

Result:

Apache + PHP:

Concurrency Level:      300
Time taken for tests:   3.515 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      255000 bytes
HTML transferred:       12000 bytes
Requests per second:    284.50 [#/sec] (mean)
Time per request:       1054.499 [ms] (mean)
Time per request:       3.515 [ms] (mean, across all concurrent requests)
Transfer rate:          70.85 [Kbytes/sec] received

Tornado Web Server:

Concurrency Level:      300
Time taken for tests:   1.907 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      168000 bytes
HTML transferred:       12000 bytes
Requests per second:    524.48 [#/sec] (mean)
Time per request:       571.993 [ms] (mean)
Time per request:       1.907 [ms] (mean, across all concurrent requests)
Transfer rate:          86.05 [Kbytes/sec] received

What do these numbers mean?

Tornado Web Server can handle 1.84 times more requests than Apache + PHP server in a given time!

–Derrick

Our sponsors:

Fedora Linux 12 is out today

Fedora Linux 12 is out today.

Here are the links to download Fedora 12:

  1. Download Fedora 12 64-Bit
  2. Download Fedora 12 32-Bit
  3. Download Fedora 12 PowerPC
  4. All versions

Suggestions:
I found that the downloading speed varies depends on which mirror you get. I suggest to test the download speed first, and re-try it (using a different mirror) if the speed is too slow.

For example, run the following command in terminal:

wget http://download.fedoraproject.org/pub/fedora/linux/releases/12/Fedora/x86_64/iso/Fedora-12-x86_64-DVD.iso

Which will show you the speed. Simply terminate the command and re-try it if the speed is too low.

Have fun with Fedora 12.

–Derrick

Our sponsors:

[Solved]Cisco RVS4000 4-port Gigabit Security Router – Slow

Recently we bought a Cisco RVS4000 4-port Gigabit Security Router and we noticed that the connection speed to the Internet was extremely slow. If we connected the server directly to the Internet (Without going through the Router), the download speed was around 80MBps, while the speed dropped down to 30 ~ 40MBps with the router with the default setting.

After disabling the IPS, the problem was gone!

Steps (IPS)- Required

  1. Go to the control panel (http://192.168.1.1)
  2. Go to the IPS tab
  3. Go to the Configuration Tab
  4. Disable the IPS function

Cisco RVS4000 4-port Gigabit Security Router - Slow Speed

Steps (Firewall) – Optional

  1. Go to the Firewall Tab
  2. Enable Firewall, DoS Protection and Block WAN Request
  3. Disable the rest

Cisco RVS4000 4-port Gigabit Security Router - Slow Speed

Looks like the IPS feature took too much resource from the router CPU.

–Derrick

Our sponsors:

Updated: What technologies (or toys) I am playing recently?

Recently I am playing the following technologies (toys):

  1. Tornado Web – Not sure how long will Apache + PHP last. Time to learn Python.
  2. Tokyo Cabinet & Tyrant – Another one of my long term plans to step away from SQL.
  3. PHP API for Tokyo Tyrant — I decide to write my own because I cannot find a good one.
  4. Moving my development platform from Windows to FreeBSD. My servers have been already on FreeBSD for many years. I think now is a good time to move my desktop systems to FreeBSD as well. Why not Linux? Oh Well…
  5. LUA – I may pick up Lua if time is permitted.

Looks like I will have a busy time other than shoveling the snow this Winter.

–Derrick

Our sponsors:

[Solved]Snow Leopard (OS X 10.6.2) can’t boot after upgrading to 10.6.2

After upgrading to Snow Leopard (OS X) 10.6.2 from 10.6.1, I found that my system could not boot, no matter what option I chose at the boot prompt (-x, -v, -s etc). After trying for nearly half an hour, I was about to give up. Finally, I tried replacing the kernel and it rocked! I think I should share my solution here because I couldn’t find something like that on Google.

What I did:
Replacing the kernel of OS X 10.6.2 by OS X 10.6. You can find the old kernel from your backup (if you have), or from the Snow Leopard installation disk.

Steps:

  1. Grab your OS X 10.6 installation disk.
  2. Boot the system using the external DVD-Rom or USB Flash Drive.
  3. After booting to the installation screen, select your language and continue.
  4. Open Terminal
  5. Type the following:
cp /mach_kernel /Volumes/XXX/

where XXX is the name of your system directory. If you are not sure how to find it, you can try to run:

df

Warning(Side Effect):
When the system upgrades to OS X 10.6.2, it upgrades both the kernel (the brain) and the apps (the body) to 10.6.2. Now, we are downgrading the brain back to 10.6. It may cause unexpected behavior because the brain and the body are speaking different languages. You can think about the problem this way: The brain is speaking an old language while the body understands the new language only. Will they get along together? May be. Only Apple knows the answer.

So do it at your own risk.

Our sponsors:

Installing Apache on Snow Leopard (OS X 10.6)

The Apache web server comes with the OS X is a bit out dated. So I decided to install a new one. After I tried installing it using mac port, it kept giving error.

Finally, I built the Apache from source, and it worked!

Grep Apache from here.

Download the file, where the link should look something like:

Unix Source: httpd-2.2.14.tar.gz

Run the following command in terminal:

tar -zxvf httpd-2.2.14.tar.gz

cd httpd-2.2.14

./configure

make

sudo make install

That’s it! Now, let’s test the webserver.

First, let’s disable the Apache that shipped with the OS X (Not the one you just install!). You can simply do it by going to:

System Preferences -> Sharing -> Web Sharing

Go back to Terminal. Make sure the default web server is not running:

sudo apachectl stop

Now, let’s verify the installations:

/usr/local/apache2/bin/apachectl -v

You should see something like this:

Server version: Apache/2.2.14 (Unix)
Server built:   Oct 24 2009 20:53:45

Now, let’s start the web server:

sudo /usr/local/apache2/bin/apachectl start

Open your browsers and access to http://localhost/.
You should see something like:

It works!

Have fun!

–Derrick

Our sponsors:

It’s a pain to use Godaddy.com’s coupon!

Godaddy.com was running a sale today: $1.99 a domain name (Coupon Code: GEO199, no other purchase is necessary) for the first year. This is a very good deal so I decide to grab four domains from them. The pain began:

1. I couldn’t use the coupon code for four domains in the same order…

» Fine. I split the order into four. I didn’t have any problem on my first order.

2. I couldn’t use the coupon code on the same user account…

» Fine. I registered a new user account and tried again.

3. I couldn’t use the coupon code on the same browser…

» Fine. I cleaned up the cache and tried again.

4. I couldn’t use the coupon code from the same IP…

» Fine. I tried using a different IP…

5. I couldn’t use the coupon code with the same credit card…

» Fine. I tried using a different credit card…

6. Finally, I got four domains for $7.96. It’s a good deal but it already spent me half an hour.

Our sponsors:

Can’t send mail from Fedora Linux … Solved!

I was having problem today to send out an email from my Fedora 11 Linux box. By default, the mail server software, Sendmail, comes with the standard installation and no configuration is required. I didn’t understand why the Sendmail didn’t work.

After a very detail investigation, I finally found out why. Here are the steps I went through to solve the problem.

1. Make sure the Sendmail is running.

netstats -na | grep LISTEN

You should see something is running on port 25.

2. Make sure the stupid SELinux Firewall is disabled.

3. Make sure the Linux Firewall allows port 25.

4. Try to connect to the port 25.

telnet localhost 25

If you have trouble to connect to the port, that means something is not work.

5. Make sure you are not blocking port 25 at the system level:
In /etc/hosts.allow

sendmail: localhost: allow

That should work!

Our sponsors:

The Flying Saucer Balloon at Colorado

Why no one thought about taking a picture of the flying balloon using infra-red camera? The Raytheon one should do the work.

Click here to read the ridiculous story.

Our sponsors: