Installing and benchmarking Nginx

Installing and benchmarking Nginx

Nginx is an open source Web server and a reverse proxy server, usually used for serving static pages and files to improve your website performance and availability.

Installing Nginx on Ubuntu

In order to authenticate the nginx repository signature and to eliminate warnings about missing gpg key during installation of the nginx package, it is necessary to add the key used to sign the nginx packages and repository to the apt program keyring. Please download this key from our web site, and add it to the aptprogram keyring with the following command:
$ sudo apt-key add nginx_signing.key

For Ubuntu replace codename with Ubuntu distribution codename, and append the following to the end of the /etc/apt/sources.list file:

$ sudo vim /etc/apt/sources.list
deb http://nginx.org/packages/ubuntu/ codename nginx
deb-src http://nginx.org/packages/ubuntu/ codename nginx

Supported Ubuntu versions:

Version Codename
10.04 lucid
11.10 oneiric
12.04 precise

And now run the following:
# apt-get update
# apt-get install nginx

Benchmarking:


In this exemple we are going to use the index.html default file created by Nginx for our tests.
Let’s go with the test!
On a Linux apache server we are going to use ab, which is a tool that comes with Apache in the Apache Benchmarking tool.
# ab -kc 1000 -n 10000 http://www.my-site.com/index.html
This will send 1000 concurrent connections 10.000 times, the results are shown like this.
# ab -kc 1000 -n 10000 http://www.my-site.com/index.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss,Zeus Technology Ltd,http://www.zeustech.net/
Licensed to The Apache Software Foundation,http://www.apache.org/

Benchmarking www.my-site.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        nginx
Server Hostname:        www.my-site.com
Server Port:            80

Document Path:          /index.html
Document Length:        151 bytes

Concurrency Level:     1000
Time taken for tests:  1.751 seconds
Complete requests:     10000
Failed requests:       0
Write errors:          0
Keep-Alive requests:   10000
Total transferred:     3600000 bytes
HTML transferred:      1510000 bytes
Requests per second:   5711.17 [#/sec] (mean)
Time per request:      175.096 [ms] (mean)
Time per request:      0.175 [ms](mean,across all concurrent requests)
Transfer rate:         2007.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10  33.2      0     126
Processing:     0  136  85.8    110     321
Waiting:        0  136  85.8    110     321
Total:          0  147  84.6    138     321

Percentage of the requests served within a certain time (ms)
  50%    138
  66%    194
  75%    211
  80%    228
  90%    269
  95%    289
  98%    302
  99%    307
 100%    321 (longest request)

Nginx vs. Apache

Nginx vs. Apache

As we can see, for a single .html file the server can serve 5711 request per second.
If we do the same test with the same condition (CPU and RAM) on Apache server we get 487 request per second !!!

All you have to do know is testing it by yourself …

Tags

Like this Article? Share it!

About the Author

Author Gravatar
Alain

I would like to change the world, but they won't give me the source code

Related Posts

Comments are closed.