• No results found

TODAY web servers become more and more

N/A
N/A
Protected

Academic year: 2021

Share "TODAY web servers become more and more"

Copied!
14
0
0

Loading.... (view fulltext now)

Full text

(1)

Web server performance analysis

Sebastian Dabkiewicz

sebastian.dabkiewicz@os3.nl

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 F

1

I

NTRODUCTION

T

ODAY web servers become more and more

important for company’s especially if their core business is web related, like a online-shop or a online-service. The web server marked is a marked with a lot of competition. There are many open- and closed source web servers available.

In the Netcraft statistics[7] the top four web servers the statistic share about 92,5 % of the whole web server marked as seen in figure 1.

Fig. 1. Netcraft March 2012 Web Server Survey

Two of the top four web servers are open-source software, namely Apache[2] and Nginx[12]. Nginx picked the in the last years

some marked share from Apache because of the good performance on static files. It is also used for load balancing.

At the 21th February 2012 the Apache httpd webserver was updated by version 2.4.11[3]. The fists big update since four years. The new Apache httpd version should increase his per-formance. So the event driven multi-processing module (MPM) is not longer experimental and the memory usage should be reduced.

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 and the maximal possible connection which the server can handle.

The chapter 4 describes the thest which are conducted.

(2)

In chapter 5 the results of the test will be discussed.

Thereafter a conclusion is given in chapter 6. Finally in chapter 7 there will be some suggestions made for future research.

2

E

NVIRONMENT

To conduction the performance of the web servers I used two 3 server in lab, two for web server and one for testing

2.1 web server

For this project two different web servers will be used, Apache 2.4.1 and Nginx 1.1.15. These two are the most used open-source web servers at the moment.

2.1.1 Apache2

Apache 2 is the most used web server in the world.

Apache can be used with different worker modules, the main three are: Prefork, Worker and Event. Every worker has his own characteristics. Below a short description of the working of each worker from the Apache httpd documentation.

2.1.1.1 Prefork:

The prefork[9] Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server. Each server process may answer incoming requests, and a parent process manages the size of the server pool. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.

2.1.1.2 Worker:

The worker[10] Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with fewer system resources than

a process-based server. However, it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.

2.1.1.3 Event:

The event[4] Multi-Processing Module (MPM) is designed to allow more requests to be served simultaneously by passing off some processing work to supporting threads, freeing up the main threads to work on new requests. It is based on the worker MPM, which implements a hybrid multi-process multi-threaded server. Run-time configuration directives are identical to those provided by worker.

2.1.2 Nginx

Nginx is a web server which was written for the Russian search engine Rambler. Because of the good configuration possibilities and performance also other sites started using the Nginx web server. Like Apache it is possible to configure the server in different ways. Nginx comes with workers.

2.1.2.1 Worker:

Multiple workers are possible in Nginx, the standard value is one. Depending on the num-ber of CPU’s and CPU cores a value can be chosen. When in doubt, setting it to the number of available CPU cores would be a good start. [11]

2.2 Server

Every server gets a Debian Squeeze 64-bit in-stallation with standard tools and a SSH-server for remote login.

2.2.1 Server configuration

For a good performance of web servers some changes to the Linux kernel default sysctl set-tings sysctl[6] have to be done. According to a paper named Performance Scalability of a Multi-Core Web Server[13] I changed the val-ues of the server. The changes can be found in appendix C.

(3)

3

M

EASURING

To be able to expect results it is necessary to measure things like network bandwidth and the maximum of connections which the server should be able to handle resulting on the avail-able bandwidth.

3.1 Iperf

Iperf[5] is a tool to measure the network band-width. Measuring the network bandwidth is important to get accurate results. For example one can have a 1 Gbps network and a 1 Gbps network switch. So one can assume to be able 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 one who is using the network in the lab in-tensely. Using the Iperf tool resulted in an network bandwidth of 941 Mbps.

3.2 Maximum number of connections After the network speed is measured one can calculate the maximal connections which could be made to the web server based on the file size. The formula is:

hit/s = bandwithM bps∗f ilesizebytes∗8bits/106bit/1byte1s

Using this formula for a 900 Mbps network and a file size of 150 bytes gives the following example:

750.000hits/s= 150900s∗8bits/106bit/1byte1s 3.3 Apache Benchmarking tool

The Apache HTTP server benchmarking tool (ab)[1] is be used to test the performance of an web server.

4

T

EST

To conduct the test static and dynamic files are used. This to see the difference with only serving a page and serving a page which is parsed at the server.

4.1 Static Files

As static file I use a small HTML-file with a size of 91 bytes and furthermore a image file with a file size of 55 Kilobytes.

4.2 Dynamic File

For the dynamic part, I used PHP[8], although PHP is not really a dynamic language, the file is be parsed at the server and then send to the client, which makes it a bit dynamic.

The used files can be found in appendix E. Each file is tested at different request and concurrency levels as seen in figure 2.

Fig. 2. Testing parameters

To test this files a script is written to au-tomate this, running the script took about 4 hours per server. The script can be found in appendix D.

5

R

ESULTS

After conducting the test a lot of data is gained. Because the test is performed at different quest levels, which gave almost the same re-sult, I only discuss the results with a request level of 250.000 requests.

5.1 Static files

5.1.1 HTML-file

The HTML-file has a file size of 91 bytes, applying the formula chapter 3 one get the following result:

1.292.582 hits/s= 91941bytesM bps 8bits/106 bit/1 byte1s As seen in in figure 3 and table 1, apache performed better then one Nginx worker 7212 requests per second against 7367 requests per second with Apache 2 event.

But when increasing the workers in Nginx (figure 4), it reaches 7742 requests per second with 4 workers, which is 500 requests per sec-ond more than Apache can handle.

(4)

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 TABLE 1 HTML-File

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 5.1.2 Image-file

The image file has a file size of 56858 bytes, applying the formula from chapter 3 one get the following result:

2.068 hits/s= 56858941bytesM bps810bits/6 bit/11sbyte

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. 5. Results of the image test

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. 6. Results of the image test

5.2 Dynamic file

5.2.1 Hello World

The result of the hello worki-file has a file size of 11 bytes, applying the formula from 3 one get the following result:

(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

10.693.181 hits/s= 11941bytesM bps 8bits/106 bit/1 byte1s As seen the maximum hits per second are about 10.5 million. As seen in figure 7 and table 5 this number is not reached.

Looking at figure 7 and table 5 one can see that the Apache web server performs much better than the Nginx server. 1873 requests per second with Nginx vs. 5142 request per seconds with the event mpm from Apache.

Fig. 7. Results of the hello world test

Worker 1 Prefork Event Worker

1 1258 1582 1565 1555 10 1873 4933 5142 5194 100 1857 4867 5118 5130 250 1859 4845 5083 5089 500 1867 4836 5070 5073 TABLE 5 Hello World

Even with using more workers in Nginx, the maximum reqests wich are processed is 3501 request per seconds with 4 workers. Which is 1600 request per seconds less then the Apache 2 worker server.

6

C

ONCLUSION

As can seen in the result section Nginx per-forms very well on static files comparing to

Fig. 8. Results of the hello world test Nginx

Worker 1 Worker 2 Worker 3 Worker 4

1 1258 1253 1256 1251 10 1873 3456 3492 3501 100 1857 3437 3468 3420 250 1859 3428 3463 3408 500 1867 3425 3446 3394 TABLE 6 Hello World Nginx

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 network connection with more bandwidth is needed or an multi server environment where the load is spread between different servers.

Using dynamic files one sees that Apache works much better than Nginx, even with more workers enabled. 1600 request per second is a lot, when assuming that a browser handles about 10 requests per domain. The CPU load was at both server around 30 % during the PHP hello test.

7

F

UTURE WORK

For a project the setup of the web servers will satisfy. But it would be desirable to have a setup with a real site, which produces an actual real load, so that the differences between both web servers better could be measured.

(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 you@example.com

<Directory />

AllowOverride none Require all denied

(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>

(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

(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;

(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;

#} }

(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

(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

(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"; ?>

(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.

Figure

Fig. 1. Netcraft March 2012 Web Server Survey Two of the top four web servers are open-source software, namely Apache[2] and Nginx[12]
Fig. 2. Testing parameters
Fig. 6. Results of the image test
Fig. 7. Results of the hello world test
+2

References

Related documents

For example, specifying date parameters in an advanced search screen (when conducting a metadata search) might not produce the expected results if the user is unaware that there

The first period of American meatless dietary reform and vegetarianism (1817-1860) covers the activities of the Bible Christian Church, Sylvester Graham, the American Vegetarian

The absorption maxima occur at higher energies than the emission maxima as expected, the difference between the absorption and emission wavelengths is the stokes shift. these

Collaboration Diagram: Set AC Options : Home Owner : Air Conditioner : Remote Access System : HACS 1: setACOptions() 4: turnOn/OffAC(status) 2: setACOptions()

Contract area (block) Project status Venture company (established) Interest owned Offshore North Caspian Sea Development INPEX North Caspian Sea, Ltd. ACG

The study will primarily focus on the current financial crisis and its impact on the growth, international trade and employment in emerging market economies (EMEs) namely China

Salinas (2009) and Haigh (1994) restate the importance of the use of three-year weighted average to smooth possible distortions caused by short-term business cycles.