こんな記事を見かけました。
LiteSpeedとNginxが増加 - Webサーバ調査
LiteSpeedってなにそれ おいしいの?状態だったのでインストールして起動までのお勉強。
ついでに簡単にabコマンドでApache LiteSpeed Nginxの性能測定してみた
※使い方とか設定とかデメリットとか信仰している宗教とかで結果は変わるので
デフォルト設定(rpm -ivh と configure && make && make install のまま)で測定
準備
コンテナ起動
[16:11:40 ~]$ docker run -it --privileged=true centos:6.6 bash
Apache インストール
[root@4f5931ad5803 ~]# yum install -y httpd php
[root@4f5931ad5803 ~]# apachectl -V
Server version: Apache/2.2.15 (Unix)
Server built: Aug 24 2015 17:52:49
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@4f5931ad5803 ~]#
LiteSpeed インストール
[root@4f5931ad5803 ~]# wget http://open.litespeedtech.com/packages/openlitespeed-1.3.12.tgz
--2015-09-09 16:31:27-- http://open.litespeedtech.com/packages/openlitespeed-1.3.12.tgz
open.litespeedtech.com をDNSに問いあわせています... 173.205.184.60
open.litespeedtech.com|173.205.184.60|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 2155783 (2.1M) [application/x-gtar]
`openlitespeed-1.3.12.tgz' に保存中
100%[=========================================================================================================================================================================>] 2,155,783 218K/s 時間 11s
2015-09-09 16:31:44 (187 KB/s) - `openlitespeed-1.3.12.tgz' へ保存完了 [2155783/2155783]
[root@4f5931ad5803 ~]# tar zxf openlitespeed-1.3.12.tgz
[root@4f5931ad5803 ~]# cd openlitespeed-1.3.12
[root@4f5931ad5803 openlitespeed-1.3.12]# ./configure
[root@4f5931ad5803 openlitespeed-1.3.12]# make
[root@4f5931ad5803 openlitespeed-1.3.12]# make install
[root@4f5931ad5803 openlitespeed-1.3.12]# /usr/local/lsws/bin/lshttpd --version
LiteSpeed/1.3.12 Open
[root@4f5931ad5803 openlitespeed-1.3.12]# rm -rf /usr/local/lsws/DEFAULT/html/
[root@4f5931ad5803 openlitespeed-1.3.12]# ln -sf /var/www/html /usr/local/lsws/DEFAULT/
[root@4f5931ad5803 openlitespeed-1.3.12]#
Nginx インストール
[root@4f5931ad5803 ~]# yum install nginx
[root@4f5931ad5803 ~]# nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
[root@4f5931ad5803 ~]#
[root@4f5931ad5803 ~]# rm -rf /usr/share/nginx/html
[root@4f5931ad5803 ~]# ln -s /var/www/html /usr/share/nginx/html
[root@4f5931ad5803 ~]# cat /etc/nginx/conf.d/default.conf |grep -v -e '#' -e '^$'
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
allow all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
allow all;
}
}
[root@4f5931ad5803 ~]#
html 用意
単純なテキストと数kBの画像3つ配置のみ
[root@4f5931ad5803 html]# ls -lh
合計 56K
-rw-r--r-- 1 root root 32K 5月 8 21:33 2012 img1.png
-rw-r--r-- 1 root root 16K 9月 23 04:25 2013 img2.png
-rw-r--r-- 1 root root 2.1K 10月 2 23:54 2014 img3.png
-rw-r--r-- 1 root root 177 9月 9 16:30 2015 index.php
[root@4f5931ad5803 html]# cat index.php
<?php
echo '
<html>
<body>
<p>測定用ページです</p>
<p><img src="./img1.png" ></p>
<p><img src="./img2.png" ></p>
<p><img src="./img3.png" ></p>
</body>
</html>
';
?>
[root@4f5931ad5803 html]#
テスト実行
[17:24:35 ~]$ docker commit 4f5931ad5803 centos:web_test
41c880aecfc3b72307611a5ae15a708e30088c61dc8a67a53f03c83fb9b6ba58
[17:25:38 ~]$
Apache
[17:28:00 ~]$ docker run -d centos:web_test apachectl -D FOREGROUND
[17:34:18 ~]$ ab -c 500 -n 1000 http://172.17.0.13/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.17.0.13 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.15
Server Hostname: 172.17.0.13
Server Port: 80
Document Path: /
Document Length: 159 bytes
Concurrency Level: 500
Time taken for tests: 1.008 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 352000 bytes
HTML transferred: 159000 bytes
Requests per second: 991.97 [#/sec] (mean)
Time per request: 504.048 [ms] (mean)
Time per request: 1.008 [ms] (mean, across all concurrent requests)
Transfer rate: 340.99 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 29 29.4 36 67
Processing: 20 332 272.5 211 935
Waiting: 18 311 276.9 186 933
Total: 83 361 290.5 219 1001
Percentage of the requests served within a certain time (ms)
50% 219
66% 250
75% 376
80% 651
90% 963
95% 988
98% 993
99% 995
100% 1001 (longest request)
LiteSpeed
[17:39:58 ~]$ docker run -d centos:web_test /usr/local/lsws/bin/lswsctrl start -D FOREGROUND
65e1a5b3f96631ffdcc58c1e395950b27f3ac98a8d2ac397f0d81f9839aefd77
[17:40:05 ~]$
[17:54:46 ~]$ docker run -d centos:web_test /usr/local/lsws/bin/litespeed -d
1f622e7c377993e4bea9a279d44e5eca4246563da80cf5bad0e8da2ccba076b9
[18:01:41 ~]$ ab -c 500 -n 1000 http://172.17.0.28:8088/index.php
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.17.0.28 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: LiteSpeed
Server Hostname: 172.17.0.28
Server Port: 8088
Document Path: /index.php
Document Length: 159 bytes
Concurrency Level: 500
Time taken for tests: 0.910 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 340000 bytes
HTML transferred: 159000 bytes
Requests per second: 1098.94 [#/sec] (mean)
Time per request: 454.982 [ms] (mean)
Time per request: 0.910 [ms] (mean, across all concurrent requests)
Transfer rate: 364.88 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 29 31.6 29 82
Processing: 26 325 122.5 350 603
Waiting: 25 298 122.0 323 584
Total: 104 354 122.5 359 664
Percentage of the requests served within a certain time (ms)
50% 359
66% 383
75% 398
80% 406
90% 465
95% 622
98% 653
99% 657
100% 664 (longest request)
[18:01:48 ~]
Nginx
[18:02:52 ~]$ docker run -d centos:web_test nginx -g "daemon off;"
ae772d6c37509c2d9ba99e8b1d3baaefd31fef48f0920cd43889a54767bdad42
[18:04:41 ~]$ ab -c 500 -n 1000 http://172.17.0.29/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 172.17.0.29 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.8.0
Server Hostname: 172.17.0.29
Server Port: 80
Document Path: /
Document Length: 177 bytes
Concurrency Level: 500
Time taken for tests: 0.600 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 423000 bytes
HTML transferred: 177000 bytes
Requests per second: 1667.05 [#/sec] (mean)
Time per request: 299.930 [ms] (mean)
Time per request: 0.600 [ms] (mean, across all concurrent requests)
Transfer rate: 688.64 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 31 30.1 37 83
Processing: 29 98 53.6 80 451
Waiting: 27 96 55.1 79 451
Total: 70 129 51.0 115 459
Percentage of the requests served within a certain time (ms)
50% 115
66% 137
75% 177
80% 187
90% 209
95% 216
98% 226
99% 228
100% 459 (longest request)
[18:04:55 ~]$
結果
min | mean | median | max | |
---|---|---|---|---|
Apache | 83 | 361 | 219 | 1001 |
LiteSpeed | 104 | 354 | 359 | 664 |
Nginx | 70 | 129 | 115 | 459 |
単純にページ返すだけならやはりNginx最強説
LiteSpeedはApacheと中身大体同じなのか同じような結果
どちらかといえばLiteSpeedの方が安定している?
あまり確認していないけどLiteSpeedはconfが大量にあったのでなにか影響しているかも
おまけ
LiteSpeedのディレクトリ構成
/usr/local/lsws/
├── DEFAULT
│ ├── cgi-bin
│ ├── conf
│ ├── fcgi-bin
│ ├── html -> /var/www/html
│ └── logs
├── add-ons
│ └── snmp_monitoring
├── admin
│ ├── cgid
│ │ └── secret
│ ├── conf
│ ├── fcgi-bin
│ ├── html -> /var/www/html
│ ├── html.open
│ │ ├── classes
│ │ │ └── ows
│ │ ├── config
│ │ ├── includes
│ │ ├── service
│ │ ├── static
│ │ │ ├── flash
│ │ │ │ └── charts_library
│ │ │ ├── images
│ │ │ │ ├── graphics
│ │ │ │ ├── icons
│ │ │ │ └── logo
│ │ │ ├── scripts
│ │ │ │ └── jcryption
│ │ │ └── styles
│ │ └── utility
│ │ └── build_php
│ ├── logs
│ ├── misc
│ └── tmp
├── bin
├── cachedata
├── conf
│ ├── cert
│ └── templates
├── docs
│ ├── css
│ └── img
├── fcgi-bin
├── gdata
├── lib
├── logs
├── modules
├── php
├── phpbuild
├── share
│ └── autoindex
│ └── icons
└── tmp
└── ocspcache
conf
xml形式なのはちょっとうれしい
admin_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<httpServerConfig>
<serverName>lshttpd</serverName>
<adminEmails></adminEmails>
<priority>0</priority>
<autoRestart>1</autoRestart>
<user>nobody</user>
<group>nobody</group>
<enableChroot>0</enableChroot>
<chrootPath>/</chrootPath>
<inMemBufSize>60M</inMemBufSize>
<autoFix503>1</autoFix503>
<loadApacheConf>0</loadApacheConf>
<mime>$SERVER_ROOT/conf/mime.properties</mime>
<showVersionNumber>0</showVersionNumber>
<autoUpdateInterval>86400</autoUpdateInterval>
<autoUpdateDownloadPkg>1</autoUpdateDownloadPkg>
<adminRoot>$SERVER_ROOT/admin/</adminRoot>
<swappingDir>/tmp/lshttpd/swap</swappingDir>
<listenerList>
<listener>
<name>Default</name>
<address>*:8088</address>
<secure>0</secure>
<vhostMapList>
<vhostMap>
<vhost>Example</vhost>
<domain>*</domain>
</vhostMap>
</vhostMapList>
</listener>
</listenerList>
・
・
・
</httpServerConfig>