Veebiserverite tarkvara vordlus

From ICO wiki
Jump to navigationJump to search


Veebiserverite tarkvara võrdlus

Autor: Priit Pääsukene

Lühidalt veebiserveritest

Veebiserverid on protsessid, mis oskavad vastata HTTP ja HTTPS päringutele. Tavakasutaja poolt vaadatuna paistab veebiserveri töö välja sel viisil, et brauseri ekraanile kuvatakse ilus ja värviline veebileht. Surfates brauseriga internetis, tähendab pea iga hiireklõps, et sinu brauser saadab veebiserverile päringuid, veebiserver vastab neile, ning tulemuseks on järjekordne lehekülg internetti kasutaja brauseri ekraanil.

Veebiserverite kõige tavalisemaks ülesandeks on erinevate failide serveerimine. See on veebiserverite hingeelust aru saamiseks hädavajalik teadmine. Veebiserverid ei joonista pilte, ei kuva flash videoid ega raputa su brauseriakent. Veebiserveri ülesandeks on vastata päringule "GET /index.php/Main_Page" vastava HTML .

Lisaks oskavad tänapäevased veebiserverid lisaks failide serveerimisele käivitada ka erinevates keeltes (php, java, .net) kirjutatud programme, kontrollida, kas antud kasutajale on õigus seda faili serveerida jms.

Võrdluse metoodikast

Lisaks subjektiivsele serverite kirjeldusele jooksutan läbi ka väikese koormustesti erinevate veebiserverite vastu. Testi käigus jälgin serverite koormust ja mälukasutust. Testimiseks kasutana apache poolt loodud utiliiti "ab" ehk apache benchmark. Et testida veebiserverit koormatuse tingimustes kasutan ühe veebiserveri testimiseks vähemalt kahte klienti. Platvormiks on Linuxi distributsiooni Debian viimane versioon (lenny).

Jõudlustesti keskkond:

[ klient1 ] <----- 1Gbit ethernet ------> [ server ]
[ klient2 ]

Veebiserverid

Apache httpd 2.2

Paigaldus:

lähtekoodi, dokumentatsiooni ja palju muud huvitavat leiab aadressilt http://httpd.apache.org

lahtipakkimine:

cd /usr/src/
tar zxvf /root/httpd-2.2.15.tar.gz
cd httpd-2.2.15

algne konfiguratsioon, kompileerimine, paigaldus: ise kompileerimiseks on vaja paljusid utiliite ja teeke. lisavõimaluste (php, geoip, ssl jms.) kompileerimiseks tuleb linux keskkonnas lisada -dev lõpuga pakke, näiteks libssl-dev. põhifunktsionaalsuse kompileerimiseks on vaja c komilaatorit gcc ja utiliiti make.

apt-get install gcc make
./configure
make
make install

vaikimisi installitakse veebiserver kataloogi /usr/local/apache2 konfiguratsioon asub failis /usr/local/apache2/conf/httpd.conf see konfiguratsioon serveerib apache dokumentatsiooni katalogist /usr/local/apache2/htdocs

Et kõik veebiserverid oleksid võrdses seisus, tekitan lihtsa kodulehekülje kausta /opt/www ja sellele vastava virtuaalse hosti:

<VirtualHost *:80>
        DocumentRoot /opt/www/
        <Directory /opt/www>
                Allow from all
        </Directory>
</VirtualHost>

Vaikimisi on kasutab apache prefork moodulit. See tähendab, et iga sissetuleva ühenduse kohta tekitatakse protsess. Jõudluse suurendamiseks suurendan maksimaalset kliente teenindavate protsesside arvu 200 paralleelse ühenduseni:

MaxClients 200

Apache Tomcat 6.0

Apache tomcat on java-s kirjutatud veebirakenduste server. Tema jooksutamiseks peab olema masinasse installeeritud java. Debiani all saab java interpretaatori pakist sun-java-jre6. Tomcat ei ole klassikaline veebiserver. Lisaks failide serveerimisele kasutatakse teda java rakenduste serveerimisel. Tegemist on applikatsiooniserveriga. Mõistlik on tomcati ette ühendusi puhverdama panna mõni muu veebiserver, näiteks httpd või nginx. Tark on ka lubada applikatsiooniserveri vastuste puhverdamine.

Tomcati installeerimiseks ja käivitamiseks on vaja lihtsalt tomcat lahti pakkida ja käivitada. Täsemad konfiguratsioonid asuvad .xml failidena kataloogis conf/. Mõistlik on tomcati jooksutamiseks tekitada eraldi kasutaja. mina valisin selleks kasutajaks "java". Kui seadistustes kõik muutmata jätta, kuulab tomcat pordis 8080.

Käsud, mis viivad tomcati käivitamiseni vaikekonfiguratsiooniga:

useradd -m java
su - java
tar zxvf apache-tomcat-6.0.26.tar.gz
cd apache-tomcat-6.0.26
rm -r webapps/ROOT
ln -s /opt/www webapps/ROOT
bin/startup.sh

Nginx

Nginx on väike, järjest suuremat populaarsust võitev veebiserver, mille saab alla laadida aadressilt http://www.nginx.org/ dokumentatsioon ja koodinäidised asuvad aadressil http://wiki.nginx.org

algseadistamine ja kompileerimine:

Vaikimisi tahetakse kompileerimisel regulaaravaldiste teeki ja räside arvutamiseks openssl teeki. debiani all saab need pakkidest libpcre3-dev ja libssl-dev . Lisaks on vajalik ka gcc ja make olemasolu.

käsud:

tar zxvf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure
make
make install

Vaikimisi installeeritakse veebiserver kausta /usr/local/nginx konfiguratsioon asub failis /usr/local/nginx/conf/nginx.conf

konfiguratsioonimuudatused:

user www;
worker_processes 10;

server {
        listen 83;
        location / {
            root   /opt/www;
            index  index.html index.htm;
        }
}

veebiserveri käivitamine:

/usr/local/nginx/sbin/nginx

Lighttpd

vaikimisi kompileerumiseks vajas lighthttpd pakki libbz2-dev. käsud:

tar zxvf lighttpd-1.4.26.tgz
cd lighttpd-1.4.26
./configure
make
make install

vaikimisi installeerus lighthttpd binaar /usr/sbin/ kataloogi käivitumiseks tuli käsitsi tekitada käivitusskript ja konfifailid. Lighthttpd veebilehel olev dokumentatsioon pakkus töötavaid näiteid.

sed -e 's/FOO/lighttpd/g' doc/rc.lighttpd > /etc/init.d/lighttpd
chmod a+rx /etc/init.d/lighttpd
install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
# update-rc.d lighttpd defaults
mkdir /var/log/lighthttpd
chown www /var/log/lighthttpd

muudatused vaikimisi konfiguratsioonis -

server.document-root        = "/opt/www/"
server.port                = 84
server.username            = "www"

Koormustest

Testimiseks kasutan utiliiti ab (apache benchmark) mis tuleb kaasa apache httpd veebiserveriga. koormustesti tegemiseks kasutan fäikest, suurt ja keskmist faili - 1b, 500kb ja 10Mb.

testin ka erinevate koormustega - 5, 100 ja 500 paralleelset ühendust.

Testi tulemused

5 paralleelset ühendust, väike fail:

httpd:

Concurrency Level:      5
Time taken for tests:   9.823 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      12450249 bytes
HTML transferred:       100002 bytes  
Requests per second:    5090.12 [#/sec] (mean)
Time per request:       0.982 [ms] (mean)     
Time per request:       0.196 [ms] (mean, across all concurrent requests)
Transfer rate:          1237.76 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Total:          0    1   0.6      1      42

load average: 0.1

tomcat

Concurrency Level:      5
Time taken for tests:   10.274 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      12150243 bytes
HTML transferred:       100002 bytes  
Requests per second:    4866.63 [#/sec] (mean)
Time per request:       1.027 [ms] (mean)     
Time per request:       0.205 [ms] (mean, across all concurrent requests)
Transfer rate:          1154.90 [Kbytes/sec] received  
Total:          0    1   2.8      1     269

Load average: 0.15

nginx

Concurrency Level:      5
Time taken for tests:   9.945 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      10550000 bytes
HTML transferred:       100000 bytes  
Requests per second:    5027.52 [#/sec] (mean)
Time per request:       0.995 [ms] (mean)     
Time per request:       0.199 [ms] (mean, across all concurrent requests)
Transfer rate:          1035.94 [Kbytes/sec] received
Total:          0    1   0.2      1       8

Load average: 0.15

lighttpd

Concurrency Level:      5
Time taken for tests:   1.696 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      2340000 bytes
HTML transferred:       20000 bytes  
Requests per second:    5894.75 [#/sec] (mean)
Time per request:       0.848 [ms] (mean)     
Time per request:       0.170 [ms] (mean, across all concurrent requests)
Transfer rate:          1347.04 [Kbytes/sec] received

Total:          0    1   0.2      1       4

Load avg: 0.15


50 paralleelset ühendust, väike fail

httpd:

Concurrency Level:      50
Time taken for tests:   2.923 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      12450000 bytes
HTML transferred:       100000 bytes  
Requests per second:    17104.57 [#/sec] (mean)
Time per request:       2.923 [ms] (mean)      
Time per request:       0.058 [ms] (mean, across all concurrent requests)
Transfer rate:          4159.22 [Kbytes/sec] received 

Total:          2    3   0.6      3      21

load average: 0.5

tomcat

Concurrency Level:      50
Time taken for tests:   4.395 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      12150486 bytes
HTML transferred:       100004 bytes  
Requests per second:    11376.29 [#/sec] (mean)
Time per request:       4.395 [ms] (mean)      
Time per request:       0.088 [ms] (mean, across all concurrent requests)
Transfer rate:          2699.75 [Kbytes/sec] received
Total:          2    4   4.8      4     109

Load average: 1.38

nginx

Concurrency Level:      50
Time taken for tests:   4.125 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      10551477 bytes
HTML transferred:       100014 bytes  
Requests per second:    12119.90 [#/sec] (mean)
Time per request:       4.125 [ms] (mean)      
Time per request:       0.083 [ms] (mean, across all concurrent requests)
Transfer rate:          2497.71 [Kbytes/sec] received 
Total:          2    4   1.2      4     137
Load average: 0.20

lighttpd

Concurrency Level:      50
Time taken for tests:   0.807 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      2340000 bytes
HTML transferred:       20000 bytes  
Requests per second:    12389.67 [#/sec] (mean)
Time per request:       4.036 [ms] (mean)      
Time per request:       0.081 [ms] (mean, across all concurrent requests)
Transfer rate:          2831.23 [Kbytes/sec] received

Total:          1    4   1.0      4      14

Load avg: 0.13

500 paralleelset ühendust, väike fail:

httpd

Concurrency Level:      500
Time taken for tests:   36.292 seconds
Complete requests:      500000        
Failed requests:        0             
Write errors:           0             
Total transferred:      124527888 bytes
HTML transferred:       1000224 bytes  
Requests per second:    13777.05 [#/sec] (mean)
Time per request:       36.292 [ms] (mean)     
Time per request:       0.073 [ms] (mean, across all concurrent requests)
Transfer rate:          3350.83 [Kbytes/sec] received 

Total:         10   36 180.6     22    9030

load average: 5.6

tomcat

Concurrency Level:      500
Time taken for tests:   4.769 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      12194226 bytes
HTML transferred:       100364 bytes  
Requests per second:    10483.95 [#/sec] (mean)
Time per request:       47.692 [ms] (mean)     
Time per request:       0.095 [ms] (mean, across all concurrent requests)
Transfer rate:          2496.95 [Kbytes/sec] received 

Total:          1   39 265.6      9    3080

Load average: 0.66

nginx

Concurrency Level:      500
Time taken for tests:   5.298 seconds
Complete requests:      50000        
Failed requests:        0            
Write errors:           0            
Total transferred:      10550422 bytes
HTML transferred:       100004 bytes  
Requests per second:    9437.40 [#/sec] (mean)
Time per request:       52.981 [ms] (mean)    
Time per request:       0.106 [ms] (mean, across all concurrent requests)
Transfer rate:          1944.70 [Kbytes/sec] received 
Total:          9   41 193.9     25    3639
Load average: 0.17

lighttpd

Concurrency Level:      500
Time taken for tests:   0.774 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      2383992 bytes
HTML transferred:       20376 bytes  
Requests per second:    12923.12 [#/sec] (mean)
Time per request:       38.690 [ms] (mean)     
Time per request:       0.077 [ms] (mean, across all concurrent requests)
Transfer rate:          3008.65 [Kbytes/sec] received

Total:         21   38   3.1     37      48

Load avg: 0.09

5 paralleelset ühendust, keskmine fail (28 kilobaiti)

httpd

Concurrency Level:      5
Time taken for tests:   30.519 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332700000 bytes
HTML transferred:       1320000000 bytes
Requests per second:    1638.31 [#/sec] (mean)
Time per request:       3.052 [ms] (mean)     
Time per request:       0.610 [ms] (mean, across all concurrent requests)
Transfer rate:          42644.10 [Kbytes/sec] received

Total:          2    3   0.7      3      40

load average: 0.8

tomcat

Concurrency Level:      5
Time taken for tests:   31.580 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332458688 bytes
HTML transferred:       1320008439 bytes
Requests per second:    1583.27 [#/sec] (mean)
Time per request:       3.158 [ms] (mean)     
Time per request:       0.632 [ms] (mean, across all concurrent requests)
Transfer rate:          41204.07 [Kbytes/sec] received 

Total:          2    3   3.3      3     314

Load average: 0.21

nginx

Concurrency Level:      5
Time taken for tests:   30.879 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1330650000 bytes
HTML transferred:       1320000000 bytes
Requests per second:    1619.20 [#/sec] (mean)
Time per request:       3.088 [ms] (mean)     
Time per request:       0.618 [ms] (mean, across all concurrent requests)
Transfer rate:          42081.87 [Kbytes/sec] received 
Total:          2    3   0.4      3      17

Load avg: 0.19

lighttpd

Concurrency Level:      5
Time taken for tests:   5.736 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      266360000 bytes
HTML transferred:       264000000 bytes
Requests per second:    1743.40 [#/sec] (mean)
Time per request:       2.868 [ms] (mean)     
Time per request:       0.574 [ms] (mean, across all concurrent requests)
Transfer rate:          45348.79 [Kbytes/sec] received

Total:          2    3   0.3      3       6

Load avg: 0.10

50 paralleelset ühendust, keskmine fail

httpd

Concurrency Level:      50
Time taken for tests:   26.712 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332755024 bytes
HTML transferred:       1320054262 bytes
Requests per second:    1871.80 [#/sec] (mean)
Time per request:       26.712 [ms] (mean)    
Time per request:       0.534 [ms] (mean, across all concurrent requests)
Transfer rate:          48723.66 [Kbytes/sec] received

Total:          2   26 229.8      6    4128

Load average: 0.55


tomcat

Concurrency Level:      50
Time taken for tests:   28.815 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332476064 bytes
HTML transferred:       1320025566 bytes
Requests per second:    1735.21 [#/sec] (mean)
Time per request:       28.815 [ms] (mean)    
Time per request:       0.576 [ms] (mean, across all concurrent requests)
Transfer rate:          45158.72 [Kbytes/sec] received
Total:          2   28 245.9      6    5018
Load Average: 0.52

nginx

Concurrency Level:      50
Time taken for tests:   27.863 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1330725935 bytes
HTML transferred:       1320075296 bytes
Requests per second:    1794.50 [#/sec] (mean)
Time per request:       27.863 [ms] (mean)    
Time per request:       0.557 [ms] (mean, across all concurrent requests)
Transfer rate:          46640.41 [Kbytes/sec] received
Total:          2   27 238.4      6    3214
Load avg: 0.30

lighttpd

Concurrency Level:      50
Time taken for tests:   4.156 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      266518100 bytes
HTML transferred:       264156684 bytes
Requests per second:    2406.26 [#/sec] (mean)
Time per request:       20.779 [ms] (mean)    
Time per request:       0.416 [ms] (mean, across all concurrent requests)
Transfer rate:          62628.00 [Kbytes/sec] received

Total:          2   18 182.6      6    3010
Load avg: 0.15

500 paralleelset ühendust, keskmine fail

httpd

Concurrency Level:      500
Time taken for tests:   40.266 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332924762 bytes
HTML transferred:       1320222476 bytes
Requests per second:    1241.74 [#/sec] (mean)
Time per request:       402.660 [ms] (mean)   
Time per request:       0.805 [ms] (mean, across all concurrent requests)
Transfer rate:          32327.12 [Kbytes/sec] received
Total:          2  359 1667.7      8   26764

load average: 0.2

tomcat

Concurrency Level:      500
Time taken for tests:   23.828 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1332533984 bytes
HTML transferred:       1320082988 bytes
Requests per second:    2098.40 [#/sec] (mean)
Time per request:       238.277 [ms] (mean)   
Time per request:       0.477 [ms] (mean, across all concurrent requests)
Transfer rate:          54612.97 [Kbytes/sec] received
Total:          1   86 567.8      6   13859
Load average: 1.12

nginx

Concurrency Level:      500
Time taken for tests:   28.148 seconds
Complete requests:      50000         
Failed requests:        0             
Write errors:           0             
Total transferred:      1330920223 bytes
HTML transferred:       1320267880 bytes
Requests per second:    1776.33 [#/sec] (mean)
Time per request:       281.479 [ms] (mean)   
Time per request:       0.563 [ms] (mean, across all concurrent requests)
Transfer rate:          46174.92 [Kbytes/sec] received
Total:          1  216 779.2      7   21007
Load avg: 0.32

lighttpd

Concurrency Level:      500
Time taken for tests:   5.377 seconds
Complete requests:      10000        
Failed requests:        0            
Write errors:           0            
Total transferred:      266462808 bytes
HTML transferred:       264101864 bytes
Requests per second:    1859.79 [#/sec] (mean)
Time per request:       268.848 [ms] (mean)   
Time per request:       0.538 [ms] (mean, across all concurrent requests)
Transfer rate:          48394.98 [Kbytes/sec] received

Total:          2  185 690.2      7    4916

Load avg: 0.11

50 paralleelset ühendust, suur fail (10Mb)

httpd

Concurrency Level:      50
Time taken for tests:   21.793 seconds
Complete requests:      100           
Failed requests:        0             
Write errors:           0             
Total transferred:      1108065520 bytes
HTML transferred:       1108035654 bytes
Requests per second:    4.59 [#/sec] (mean)
Time per request:       10896.638 [ms] (mean)
Time per request:       217.933 [ms] (mean, across all concurrent requests)
Transfer rate:          49652.71 [Kbytes/sec] received

Total:        208 9541 5294.6   9858   20593

load average: 0.0

tomcat

Concurrency Level:      50
Time taken for tests:   21.006 seconds
Complete requests:      100           
Failed requests:        0             
Write errors:           0             
Total transferred:      1142674328 bytes
HTML transferred:       1142643818 bytes
Requests per second:    4.76 [#/sec] (mean)
Time per request:       10502.895 [ms] (mean)
Time per request:       210.058 [ms] (mean, across all concurrent requests)
Transfer rate:          53123.11 [Kbytes/sec] received
Total:       3372 7963 2031.2   8257   14881

Load 0.21

nginx

Concurrency Level:      50
Time taken for tests:   20.229 seconds
Complete requests:      100           
Failed requests:        0             
Write errors:           0             
Total transferred:      1079869584 bytes
HTML transferred:       1079845560 bytes
Requests per second:    4.94 [#/sec] (mean)
Time per request:       10114.699 [ms] (mean)
Time per request:       202.294 [ms] (mean, across all concurrent requests)
Transfer rate:          52130.08 [Kbytes/sec] received 
Total:       4791 8610 2151.8   8533   14057

Load avg: 0.10

nginx

Concurrency Level:      50
Time taken for tests:   19.610 seconds
Complete requests:      100           
Failed requests:        0             
Write errors:           0             
Total transferred:      1105439924 bytes
HTML transferred:       1105414976 bytes
Requests per second:    5.10 [#/sec] (mean)
Time per request:       9804.952 [ms] (mean)
Time per request:       196.099 [ms] (mean, across all concurrent requests)
Transfer rate:          55050.30 [Kbytes/sec] received

Total:       2071 7095 3019.6   6678   16009

Load avg: 0.04

lighttpd

Concurrency Level:      50
Time taken for tests:   19.557 seconds
Complete requests:      100           
Failed requests:        0             
Write errors:           0             
Total transferred:      1151063328 bytes
HTML transferred:       1151034118 bytes
Requests per second:    5.11 [#/sec] (mean)
Time per request:       9778.541 [ms] (mean)
Time per request:       195.571 [ms] (mean, across all concurrent requests)
Transfer rate:          57477.14 [Kbytes/sec] received 

Total:       2802 8198 3605.2   7041   15664

Load average: 0.04