0% found this document useful (0 votes)
225 views14 pages

Web Server Performance Analysis PDF

The document analyzes and compares the performance of the Apache 2.4.1 and Nginx 1.0.12 web servers. Tests were conducted using static and dynamic files to compare how each server handles the different types of requests. Nginx performed significantly better for static files, while Apache performed better for dynamic files. The tests measured aspects like response time, number of requests served, and server load under increasing loads to determine which server is better suited for different tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
225 views14 pages

Web Server Performance Analysis PDF

The document analyzes and compares the performance of the Apache 2.4.1 and Nginx 1.0.12 web servers. Tests were conducted using static and dynamic files to compare how each server handles the different types of requests. Nginx performed significantly better for static files, while Apache performed better for dynamic files. The tests measured aspects like response time, number of requests served, and server load under increasing loads to determine which server is better suited for different tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 1

Web server performance analysis


Sebastian Dabkiewicz
[email protected]

Abstract—Web servers become more and more important for company’s which core business is done on the internet.
Several web server software is available and is used. In this report a comparison is made between the Apache 2.4.1
web server and the Nginx 1.0.12 web server. During the tests with static and dynamic files the differences between both
can be seen. Nginx performed very good using static files, while Apache performed much better using dynamic files. So
for every specific task is a web server available.

Index Terms—Apache httpd, Nginx, Web server, performance

1 I NTRODUCTION some marked share from Apache because of


the good performance on static files. It is also
T ODAY web servers become more and more
important for company’s especially if their
core business is web related, like a online-shop
used for load balancing.
At the 21th February 2012 the Apache httpd
or a online-service. The web server marked webserver was updated by version 2.4.11[3].
is a marked with a lot of competition. There The fists big update since four years. The new
are many open- and closed source web servers Apache httpd version should increase his per-
available. formance. So the event driven multi-processing
In the Netcraft statistics[7] the top four web module (MPM) is not longer experimental and
servers the statistic share about 92,5 % of the the memory usage should be reduced.
whole web server marked as seen in figure 1. In this report a comparisation will be made
betwee Apache 2.4.1 and Nginx 1.0.12.

1.1 Research questions


How compares the Apache httpd 2.4.1 web
server against Nginx 1.0.12?
- How is the performance using static
pages?
- How is the performance using dynamic
pages?
- What is the server load?

In chapter 2 a global situation of the


environment and the used software if given.

Chapter 3 describes the methods which


are used to determine the network bandwidth
Fig. 1. Netcraft March 2012 Web Server Survey and the maximal possible connection which
the server can handle.
Two of the top four web servers are
open-source software, namely Apache[2] and The chapter 4 describes the thest which
Nginx[12]. Nginx picked the in the last years are conducted.
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 2

a process-based server. However, it retains


In chapter 5 the results of the test will be much of the stability of a process-based server
discussed. by keeping multiple processes available, each
with many threads.
Thereafter a conclusion is given in chapter 6.
2.1.1.3 Event:
Finally in chapter 7 there will be some The event[4] Multi-Processing Module (MPM)
suggestions made for future research. is designed to allow more requests to be served
simultaneously by passing off some processing
work to supporting threads, freeing up the
2 E NVIRONMENT
main threads to work on new requests. It is
To conduction the performance of the web based on the worker MPM, which implements
servers I used two 3 server in lab, two for web a hybrid multi-process multi-threaded server.
server and one for testing Run-time configuration directives are identical
to those provided by worker.
2.1 web server
For this project two different web servers will 2.1.2 Nginx
be used, Apache 2.4.1 and Nginx 1.1.15. These Nginx is a web server which was written for
two are the most used open-source web servers the Russian search engine Rambler. Because
at the moment. of the good configuration possibilities and
performance also other sites started using the
2.1.1 Apache2 Nginx web server. Like Apache it is possible to
Apache 2 is the most used web server in the configure the server in different ways. Nginx
world. comes with workers.
Apache can be used with different worker
modules, the main three are: Prefork, Worker 2.1.2.1 Worker:
and Event. Every worker has his own Multiple workers are possible in Nginx, the
characteristics. Below a short description of standard value is one. Depending on the num-
the working of each worker from the Apache ber of CPU’s and CPU cores a value can be
httpd documentation. chosen. When in doubt, setting it to the number
of available CPU cores would be a good start.
2.1.1.1 Prefork: [11]
The prefork[9] Multi-Processing Module
(MPM) implements a non-threaded, pre-
forking web server. Each server process may 2.2 Server
answer incoming requests, and a parent
process manages the size of the server pool. Every server gets a Debian Squeeze 64-bit in-
It is appropriate for sites that need to avoid stallation with standard tools and a SSH-server
threading for compatibility with non-thread- for remote login.
safe libraries. It is also the best MPM for
isolating each request, so that a problem with
2.2.1 Server configuration
a single request will not affect any other.
For a good performance of web servers some
2.1.1.2 Worker: changes to the Linux kernel default sysctl set-
The worker[10] Multi-Processing Module tings sysctl[6] have to be done. According to
(MPM) implements a hybrid multi-process a paper named Performance Scalability of a
multi-threaded server. By using threads to Multi-Core Web Server[13] I changed the val-
serve requests, it is able to serve a large number ues of the server. The changes can be found in
of requests with fewer system resources than appendix C.
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 3

3 M EASURING 4.1 Static Files


To be able to expect results it is necessary to As static file I use a small HTML-file with a
measure things like network bandwidth and size of 91 bytes and furthermore a image file
the maximum of connections which the server with a file size of 55 Kilobytes.
should be able to handle resulting on the avail-
able bandwidth. 4.2 Dynamic File
For the dynamic part, I used PHP[8], although
3.1 Iperf PHP is not really a dynamic language, the file
Iperf[5] is a tool to measure the network band- is be parsed at the server and then send to the
width. Measuring the network bandwidth is client, which makes it a bit dynamic.
important to get accurate results. For example The used files can be found in appendix E.
one can have a 1 Gbps network and a 1 Gbps Each file is tested at different request and
network switch. So one can assume to be able concurrency levels as seen in figure 2.
to transfer data at 1 Gbps, but due different
quality of the used hardware inside the switch
the speed real speed could be slower. Also
other users on the same switch can influence
the speed.
Therefore I conduct my testing in the evening
hours so that the actual chance to be the only Fig. 2. Testing parameters
one who is using the network in the lab in-
tensely. Using the Iperf tool resulted in an To test this files a script is written to au-
network bandwidth of 941 Mbps. tomate this, running the script took about 4
hours per server. The script can be found in
3.2 Maximum number of connections appendix D.
After the network speed is measured one
can calculate the maximal connections which 5 R ESULTS
could be made to the web server based on the After conducting the test a lot of data is gained.
file size. The formula is: Because the test is performed at different re-
quest levels, which gave almost the same re-
bps∗106 bit/1s
hit/s = bandwithM
f ilesizebytes∗8bits/1byte sult, I only discuss the results with a request
level of 250.000 requests.
Using this formula for a 900 Mbps network
and a file size of 150 bytes gives the following 5.1 Static files
example:
5.1.1 HTML-file
900s∗106 bit/1s The HTML-file has a file size of 91 bytes,
750.000hits/s = 150∗8bits/1byte
applying the formula chapter 3 one get the
following result:
3.3 Apache Benchmarking tool
M bps ∗ 106 bit/1s
The Apache HTTP server benchmarking tool 1.292.582 hits/s = 91941bytes ∗ 8 bits/ 1 byte
(ab)[1] is be used to test the performance of an
As seen in in figure 3 and table 1, apache
web server.
performed better then one Nginx worker 7212
requests per second against 7367 requests per
4 T EST second with Apache 2 event.
To conduct the test static and dynamic files But when increasing the workers in Nginx
are used. This to see the difference with only (figure 4), it reaches 7742 requests per second
serving a page and serving a page which is with 4 workers, which is 500 requests per sec-
parsed at the server. ond more than Apache can handle.
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 4

Here can be seen that the network is the


bottleneck, and only 2.068 hits can be expected,
which is almost be reached during the test. All
web servers reached about 2000 requests per
second.

Fig. 3. Results of the HTML test

Worker 1 Prefork Event Worker


1 2591 1910 1877 1919
10 7212 7259 7367 7196
100 7095 6919 7328 7090
250 6990 6899 7297 7085
500 7038 6902 7278 7077 Fig. 5. Results of the image test
TABLE 1
HTML-File Worker 1 Prefork Event Worker
1 554 624 568 551
10 1989 1995 1995 1995
100 1992 1996 1996 1996
250 1989 1997 1994 1994
500 1987 1997 1194 1994

TABLE 3
Image File

The result of the image test using different


workers in Nginx can be found below in fig-
ure 6.
Fig. 4. Results of the HTML test for Nginx

Worker 1 Worker 2 Worker 3 Worker 4


1 2591 2582 2588 2565
10 7212 7294 7274 7265
100 7095 7310 7404 7453
250 6990 7659 7581 7681
500 7038 7601 7503 7742

TABLE 2
HTML-File Nginx
Fig. 6. Results of the image test

5.1.2 Image-file
5.2 Dynamic file
The image file has a file size of 56858 bytes,
applying the formula from chapter 3 one get 5.2.1 Hello World
the following result: The result of the hello worki-file has a file size
of 11 bytes, applying the formula from 3 one
941 M bps ∗ 106 bit/1s
2.068 hits/s = 56858 bytes ∗ 8 bits/ 1 byte get the following result:
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 5

Worker 1 Worker 2 Worker 3 Worker 4


1 554 553 724 632
10 1989 1987 1987 1989
100 1992 1992 1992 1990
250 1989 1990 1990 1989
500 1987 1987 1987 1989

TABLE 4
Image File-Nginx

941 M bps ∗ 106 bit/1s


10.693.181 hits/s = 11 bytes ∗ 8 bits/ 1 byte
Fig. 8. Results of the hello world test Nginx
As seen the maximum hits per second are Worker 1 Worker 2 Worker 3 Worker 4
about 10.5 million. As seen in figure 7 and 1 1258 1253 1256 1251
10 1873 3456 3492 3501
table 5 this number is not reached.
100 1857 3437 3468 3420
Looking at figure 7 and table 5 one can see 250 1859 3428 3463 3408
that the Apache web server performs much 500 1867 3425 3446 3394
better than the Nginx server. 1873 requests per
TABLE 6
second with Nginx vs. 5142 request per seconds
Hello World Nginx
with the event mpm from Apache.

Apache. Nginx could handle about 500 re-


quests per seconds more then Apache.
The image test didn’t give any surprise, be-
cause the large file size the network was the
bottleneck, and every server reaches about 2000
request per second. The CPU of the servers
where almost idle during the test. So for a site
with much large files and much visitors an
Fig. 7. Results of the hello world test network connection with more bandwidth is
needed or an multi server environment where
the load is spread between different servers.
Worker 1 Prefork Event Worker
1 1258 1582 1565 1555
Using dynamic files one sees that Apache
10 1873 4933 5142 5194 works much better than Nginx, even with more
100 1857 4867 5118 5130 workers enabled. 1600 request per second is
250 1859 4845 5083 5089 a lot, when assuming that a browser handles
500 1867 4836 5070 5073
about 10 requests per domain. The CPU load
TABLE 5 was at both server around 30 % during the PHP
Hello World hello test.

Even with using more workers in Nginx, the 7 F UTURE WORK


maximum reqests wich are processed is 3501 For a project the setup of the web servers will
request per seconds with 4 workers. Which is satisfy. But it would be desirable to have a
1600 request per seconds less then the Apache setup with a real site, which produces an actual
2 worker server. real load, so that the differences between both
web servers better could be measured.
6 C ONCLUSION
As can seen in the result section Nginx per-
forms very well on static files comparing to
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 6

A PPENDIX A
A PACHE C ONFIG
A.1 httpd.conf
ServerRoot "/usr/local/apache2"

Listen 80

LoadModule authn_file_module modules/mod_authn_file.so


LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php

AddType text/html .php

<IfModule unixd_module>

User daemon
Group daemon

</IfModule>

# ’Main’ server configuration


#
ServerAdmin [email protected]

<Directory />
AllowOverride none
Require all denied
</Directory>
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 7

DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">

Options Indexes FollowSymLinks

AllowOverride None

Require all granted


</Directory>

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

<Files ".ht*">
Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""


combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"
%I %O" combinedio
</IfModule>

CustomLog "logs/access_log" common

</IfModule>

<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
</IfModule>

<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>

<IfModule mime_module>
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 8

TypesConfig conf/mime.types

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

</IfModule>

# Supplemental configuration
#

textless IfModule proxy_html_module >


Include conf/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 9

A PPENDIX B
N GINX C ONFIG
B.1 nginx.conf
user nginx;
worker_processes 4;
worker_rlimit_nofile 65535;

error_log /var/log/nginx/error.log warn;


pid /var/run/nginx.pid;

events {
# worker_connections 1024;
worker_connections 16384;
use epoll;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main ’$remote_addr - $remote_user [$time_local] "$request"



’$status $body_bytes_sent "$http_referer" ’
’"$http_user_agent" "$http_x_forwarded_for"’;

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 90;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

B.2 default.conf
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 10

location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html


#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80


#
#location ˜ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000


#
location ˜ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
}

# deny access to .htaccess files, if Apache’s document root


# concurs with nginx’s one
#
#location ˜ /\.ht {
# deny all;
#}
}
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 11

A PPENDIX C
S ERVER CONFIG
fs.file-max = 5000000
net.core.netdev_max_backlog = 400000
net.core.optmem_max = 10000000
net.core.rmem_default = 10000000
net.core.rmem_max = 10000000
net.core.somaxconn = 100000
net.core.wmem_default = 10000000
net.core.wmem_max = 10000000
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_congestion_control = bic
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_max_syn_backlog = 12000
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_mem = 30000000 30000000 30000000
net.ipv4.tcp_rmem = 30000000 30000000 30000000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_wmem = 30000000 30000000 30000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 12

A PPENDIX D
AB SCRIPT
#!/bin/bash

for i in 1000 10000 100000 250000 500000

do
for j in 1 10 100 250 500
do
echo "ab -n $i -c $j -k http://145.100.104.16/index.html"
ab -n $i -c $j http://145.100.104.16/index.html >>
apache/index-$j-$i.txt
done
done

for a in 1000 10000 100000 250000 500000

do
for b in 1 10 100 250 500
do
echo "ab -n $a -c $b -k http://145.100.104.16/uitzicht.JPG"
ab -n $a -c $b http://145.100.104.16/uitzicht.JPG >>
apache/uitzicht-$b-$a.txt
done
done

for c in 1000 10000 100000 250000 500000

do
for d in 1 10 100 250 500
do
echo "ab -n $c -c $d -k http://145.100.104.16/hello.php"
ab -n $c -c $d http://145.100.104.16/hello.php >> nignx2/hello-$d-$c.txt
done
done

for e in 1000 10000 100000 250000 500000

do
for f in 1 10 100 250 500
do
echo "ab -n $e -c $f -k http://145.100.104.16/index.php"
ab -n $e -c $f http://145.100.104.16/index.php >> apache/indexphp-$f-$e.txt
done
done
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 13

A PPENDIX E
T EST FILES
E.1 index.html
<html>
<head>
<title>Server X
</head>
<body>
<h1>Server X
</body>
</html>

E.2 uizicht.JPG

Fig. 9. file: uitzicht.JPG, source: Sebastian Dabkiewicz

E.3 index.php
<?php
phpinfo();
?>

E.4 hello.php
<?php
echo "Hello World";
?>
WEB SERVER PERFORMANCE ANALYSIS, LIA PROJECT, 2ND APRIL 2010 14

R EFERENCES
[1] ab - apache http server benchmarking tool. Website. available at http://httpd.apache.org/docs/2.0/programs/ab.html; on
01st April 2012.
[2] Apache httpd. Website. available at http://httpd.apache.org/; on 01st April 2012.
[3] Apache httpd 2.4.1. Website. available at http://www.apache.org/dist/httpd/Announcement2.4.html; on 01st April 2012.
[4] Event mpm. Website. available at http://httpd.apache.org/docs/2.4/en/mod/event.html; on 01st April 2012.
[5] Iperf. Website. available at http://iperf.sourceforge.net/; on 01st April 2012.
[6] Linux Kernel. Linux IP Sysctl Documentation. available at http://www.kernel.org/doc/Documentation/networking/ip-sysctl.
txt; on 01st April 2012.
[7] Netcraft. Website. available at http://news.netcraft.com/; on 01st April 2012.
[8] Php. Website. available at http://www.php.net/; on 01st April 2012.
[9] Prefork mpm. Website. available at http://httpd.apache.org/docs/2.4/en/mod/prefork.html; on 01st April 2012.
[10] Worker mpm. Website. available at http://httpd.apache.org/docs/2.4/en/mod/worker.html; on 01st April 2012.
[11] Worker processes. Website. available at http://nginx.org/en/docs/ngx\ core\ module.html\#worker\ processes; on 01st
April 2012.
[12] Nginx. Website. available at http://nginx.org/; on 01st April 2012.
[13] Bryan Veal and Annie Foong. Performance Scalability of a Multi-Core Web Server, November 2007.

You might also like