・ Web系SE募集 (技術開発部開発系エンジニア・Java/Tomcat 420万円~750万円)
   ・ 社内SE募集 (業務系システムの開発・社内イントラ)

Apache Benchの最近のブログ記事


 ab - Apache HTTP server benchmarking tool
    http://www.apache.jp/manual/programs/ab.html

同時発行数を100リクエスト、10000回のアクセスを実行。
$ ab -n 10000 -c 100 
DBへのアクセスはせず、「Hello, world.」を返すぐらいだけのものでベンチマークをとります。
abコマンド実行中にtopコマンドでメモリの使用状況を確認。

◆メモリ(1プロセスあたり)

Ruby on Rails + mod_rails (mod_passenger)

Mem:    256400k total,   253792k used,     2608k free,      540k buffers
Swap:   524280k total,    18708k used,   505572k free,    21388k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3041 suzu      25   0 45680  31m 1584 R 10.9 12.5   0:23.41 ruby
 3055 apache    15   0 12988 1888 1288 S  0.4  0.7   0:00.85 httpd

Django + mod_python
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4207 apache    15   0 22408  14m 2272 S  8.0  5.6   0:03.64 httpd
    
Django + mod_wsgi
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3019 apache    15   0 18072  10m 2284 S  7.0  4.0   0:05.13 httpd

Pylons + mod_wsgi
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2915 apache    19   0 23920  14m 2568 R  0.0  5.7   0:07.15 httpd

◇結果

Ruby on Rails + mod_rails だけ、Swapを使ってしまいました。
また、Apacheのプロセスとは別に、Rubyのプロセスも必要で、メモリも消費するようにみえます。
一番メモリを消費しないのは、
Django + mod_wsgi
でした。


◆処理速度

Ruby on Rails + mod_rails (mod_passenger)
    Requests per second:    175.59 [#/sec] (mean)

Django + mod_python
    Requests per second:    576.02 [#/sec] (mean)
    
Django + mod_wsgi
    Requests per second:    854.67 [#/sec] (mean)

Pylons + mod_wsgi
    Requests per second:    380.65 [#/sec] (mean)

◇結果

秒間あたりの処理能力が一番よいのは
Django + mod_wsgi 
であり、最下位が
Ruby on Rails + mod_rails
でありました。今回の検証では、Ruby on Rails + mod_rails は、Swapを使用したため
速度比較としては、平等ではないかもしれません。

■総合結果

総合的にみても、Django + mod_wsgi が良く、Ruby on Rails + mod_rails は、最下位となりました。





Pylons Ver.0.9 + mod_wsgi で "Hello, world!" 』で用意したもので確認します。

$ cat /home/httpd/vhost/pylons/pylons_with_mod_wsgi/pylons_with_mod_wsgi/controllers/hello.py
import logging

from pylons_with_mod_wsgi.lib.base import *

log = logging.getLogger(__name__)

class HelloController(BaseController):

    def index(self):
        # Return a rendered template
        #   return render('/some/template.mako')
        # or, Return a response
        return 'Hello World. - Pylons with mod_wsgi'



$ curl http://localhost/hello/
Hello World. - Pylons with mod_wsgi

Apache Bench
$ ab -n 10000 -c 100  "http://localhost/hello/"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (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
Finished 10000 requests


Server Software:        Apache/2.2.9
Server Hostname:        localhost
Server Port:            80

Document Path:          /hello/
Document Length:        35 bytes

Concurrency Level:      100
Time taken for tests:   26.270970 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2990897 bytes
HTML transferred:       350105 bytes
Requests per second:    380.65 [#/sec] (mean)
Time per request:       262.710 [ms] (mean)
Time per request:       2.627 [ms] (mean, across all concurrent requests)
Transfer rate:          111.15 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    9  15.1      0      90
Processing:    50  251 165.4    230    8360
Waiting:        0  226  79.7    220    2780
Total:         90  260 166.0    240    8400

Percentage of the requests served within a certain time (ms)
  50%    240
  66%    240
  75%    250
  80%    260
  90%    280
  95%    310
  98%    760
  99%   1030
 100%   8400 (longest request)
メモリ使用状況
top - 17:29:26 up 15 min,  2 users,  load average: 16.66, 8.66, 4.29
Tasks:  62 total,  22 running,  40 sleeping,   0 stopped,   0 zombie
Cpu(s): 88.4%us,  8.7%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  2.9%si,  0.0%st
Mem:    256400k total,   253604k used,     2796k free,     3656k buffers
Swap:   524280k total,        0k used,   524280k free,    32604k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2915 apache    19   0 23920  14m 2568 R  0.0  5.7   0:07.15 httpd
 2916 apache    19   0 23920  14m 2568 R  0.0  5.7   0:06.72 httpd
 2928 apache    19   0 23920  14m 2564 R  0.0  5.7   0:08.05 httpd
 2933 apache    19   0 23920  14m 2564 R  0.0  5.7   0:07.03 httpd
 2936 apache    19   0 23920  14m 2564 R  0.0  5.7   0:05.65 httpd
 2942 apache    19   0 23920  14m 2564 R 14.5  5.7   0:06.13 httpd
 2945 apache    19   0 23920  14m 2564 R 14.5  5.7   0:06.25 httpd
 2946 apache    19   0 23920  14m 2564 R  0.0  5.7   0:06.83 httpd
 2948 apache    19   0 23920  14m 2564 R  0.0  5.7   0:04.61 httpd
 2951 apache    19   0 23920  14m 2564 R  0.0  5.7   0:04.15 httpd
 2952 apache    19   0 23920  14m 2564 R  0.0  5.7   0:04.13 httpd
 2953 apache    19   0 23920  14m 2564 R  0.0  5.7   0:04.21 httpd
 2954 apache    19   0 23920  14m 2564 R  0.0  5.7   0:04.21 httpd
 2958 apache    19   0 23920  14m 2564 R  8.7  5.6   0:02.91 httpd
 2959 apache    19   0 23920  14m 2564 R 14.5  5.6   0:02.91 httpd
 2960 apache    19   0 23920  14m 2564 R 14.5  5.6   0:02.85 httpd
 2963 apache    19   0 23920  14m 2564 R 14.5  5.6   0:01.81 httpd
 2962 apache    19   0 23920  14m 2564 R  0.0  5.6   0:01.63 httpd
 2964 apache    19   0 23920  14m 2564 R  8.7  5.6   0:01.77 httpd
 2965 apache    19   0 23920  14m 2564 R  0.0  5.6   0:01.65 httpd

Django Ver.1 + mod_wsgi で "Hello, world!" 』で用意したもので確認します。

ApacheのConfファイル

WSGIScriptAlias / "/home/httpd/vhost/django/django_with_wsgi/apache/django.wsgi"

<Directory /home/httpd/vhost/django/django_with_wsgi/apache>
Order allow,deny
Allow from all
</Directory>
$ cat django_with_wsgi/hello/views.py
# Create your views here.
from django.http import HttpResponse

def index(request):
return HttpResponse("Hello, world. Django with mod_wsgi")

$ curl  "http://localhost/hello/"
Hello, world. Django with mod_wsgi
Apache Bench
$  ab -n 10000 -c 100   "http://localhost/hello/"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (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
Finished 10000 requests


Server Software:        Apache/2.2.9
Server Hostname:        localhost
Server Port:            80

Document Path:          /hello/
Document Length:        35 bytes

Concurrency Level:      100
Time taken for tests:   11.700486 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2560000 bytes
HTML transferred:       350000 bytes
Requests per second:    854.67 [#/sec] (mean)
Time per request:       117.005 [ms] (mean)
Time per request:       1.170 [ms] (mean, across all concurrent requests)
Transfer rate:          213.67 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.9      0      30
Processing:     0  116 179.9    100    4920
Waiting:        0  109 105.1    100    4290
Total:         30  116 179.9    100    4920

Percentage of the requests served within a certain time (ms)
  50%    100
  66%    100
  75%    100
  80%    100
  90%    110
  95%    120
  98%    450
  99%    670
 100%   4920 (longest request)

メモリ使用状況
top - 15:22:43 up  2:16,  2 users,  load average: 7.01, 3.76, 2.02
Tasks:  65 total,   4 running,  61 sleeping,   0 stopped,   0 zombie
Cpu(s): 81.4%us, 12.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  6.6%si,  0.0%st
Mem:    256400k total,   253468k used,     2932k free,     6644k buffers
Swap:   524280k total,        0k used,   524280k free,    79956k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3019 apache    15   0 18072  10m 2284 S  7.0  4.0   0:05.13 httpd
 3058 apache    15   0 18072  10m 2284 S  6.3  4.0   0:01.54 httpd
 3006 apache    15   0 18072  10m 2284 S  5.3  4.0   0:05.14 httpd
 3054 apache    15   0 18072  10m 2284 S  5.3  4.0   0:02.11 httpd
 3055 apache    15   0 18072  10m 2284 S  5.3  4.0   0:01.66 httpd
 3060 apache    15   0 18072  10m 2284 S  5.3  4.0   0:00.64 httpd
 3031 apache    15   0 18072  10m 2284 S  5.0  4.0   0:02.85 httpd
 3026 apache    15   0 18072  10m 2284 S  4.7  4.0   0:03.48 httpd
 3050 apache    15   0 18072  10m 2284 S  4.7  4.0   0:01.85 httpd
 3023 apache    15   0 18072  10m 2284 S  4.3  4.0   0:05.07 httpd
 3033 apache    15   0 18072  10m 2284 S  4.3  4.0   0:02.89 httpd
 3041 apache    15   0 18072  10m 2284 S  4.3  4.0   0:01.95 httpd
 3044 apache    15   0 18072  10m 2284 S  4.3  4.0   0:01.98 httpd
 3056 apache    15   0 18072  10m 2284 S  4.0  4.0   0:01.67 httpd
 3038 apache    15   0 18072  10m 2284 S  3.3  4.0   0:01.89 httpd
 3048 apache    15   0 18072  10m 2284 S  3.3  4.0   0:01.73 httpd
 3052 apache    15   0 18072  10m 2284 S  3.3  4.0   0:01.88 httpd
 3049 apache    15   0 18072  10m 2284 S  3.0  4.0   0:01.85 httpd
 3053 apache    15   0 18072  10m 2284 S  3.0  4.0   0:02.03 httpd
 3047 apache    15   0 18072  10m 2284 S  2.7  4.0   0:01.75 httpd

Apacheの設定ファイル
LoadModule python_module      modules/mod_python.so

<Location /django_with_mod_python>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE django_with_mod_python.settings
PythonOption django.root /django_with_mod_python
#PythonDebug On
PythonPath "['/home/httpd/vhost/django'] + sys.path"
</Location>
$ cat hello/views.py
# Create your views here.
from django.http import HttpResponse

def index(request):
return HttpResponse("Hello, world. - Django with mod_python")

$ curl "http://localhost/django_with_mod_python/hello/"
Hello, world. - Django with mod_python

Apache Bench
$  ab -n 10000 -c 100 "http://localhost/django_with_mod_python/hello/"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (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
Finished 10000 requests


Server Software:        Apache/2.2.9
Server Hostname:        localhost
Server Port:            80

Document Path:          /django_with_mod_python/hello/
Document Length:        39 bytes

Concurrency Level:      100
Time taken for tests:   17.360633 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2640000 bytes
HTML transferred:       390000 bytes
Requests per second:    576.02 [#/sec] (mean)
Time per request:       173.606 [ms] (mean)
Time per request:       1.736 [ms] (mean, across all concurrent requests)
Transfer rate:          148.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    4  11.0      0     130
Processing:    30  167 114.3    150    3860
Waiting:       10  150  38.1    150     600
Total:         80  172 114.9    150    3870

Percentage of the requests served within a certain time (ms)
  50%    150
  66%    160
  75%    170
  80%    170
  90%    180
  95%    230
  98%    480
  99%    620
 100%   3870 (longest request)

メモリ使用状況
top - 15:41:52 up  2:35,  2 users,  load average: 7.71, 2.64, 1.49
Tasks:  65 total,  13 running,  52 sleeping,   0 stopped,   0 zombie
Cpu(s): 83.8%us, 11.5%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  4.8%si,  0.0%st
Mem:    256400k total,   253500k used,     2900k free,     3544k buffers
Swap:   524280k total,        0k used,   524280k free,    40468k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4207 apache    15   0 22408  14m 2272 S  8.0  5.6   0:03.64 httpd
 4210 apache    15   0 22408  14m 2272 R  7.3  5.6   0:01.61 httpd
 4202 apache    15   0 22408  14m 2272 S  7.0  5.6   0:03.67 httpd
 4217 apache    15   0 22408  14m 2272 S  6.1  5.6   0:01.51 httpd
 4218 apache    15   0 22408  14m 2272 R  5.4  5.6   0:01.16 httpd
 4186 apache    15   0 22408  14m 2272 S  4.8  5.6   0:01.27 httpd
 4211 apache    16   0 22408  14m 2272 R  4.8  5.6   0:01.24 httpd
 4185 apache    15   0 22408  14m 2272 S  4.5  5.6   0:02.52 httpd
 4204 apache    15   0 22408  14m 2272 S  4.5  5.6   0:03.39 httpd
 4213 apache    15   0 22408  14m 2272 S  4.5  5.6   0:01.28 httpd
 4215 apache    16   0 22408  14m 2272 R  4.5  5.6   0:01.50 httpd
 4220 apache    15   0 22408  14m 2272 S  4.1  5.6   0:00.53 httpd
 4184 apache    15   0 22408  14m 2272 S  3.8  5.6   0:02.43 httpd
 4201 apache    15   0 22408  14m 2272 S  3.8  5.6   0:03.73 httpd
 4216 apache    16   0 22408  14m 2272 R  3.8  5.6   0:01.48 httpd
 4182 apache    15   0 22408  14m 2272 S  3.5  5.6   0:03.31 httpd
 4198 apache    15   0 22408  14m 2272 S  3.2  5.6   0:03.05 httpd
 4214 apache    15   0 22408  14m 2272 S  3.2  5.6   0:01.33 httpd
 4209 apache    15   0 22408  14m 2272 S  2.9  5.6   0:00.98 httpd
 4212 apache    16   0 22408  14m 2272 R  2.9  5.6   0:01.39 httpd


Ruby on Rails Ver.2 + mod_rails (mod_passenger) で "Hello, world!" 』で用意したもので確認します。



Apache設定ファイル
$ cat mod_rails.conf
LoadModule passenger_module   /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot                 /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby                 /usr/bin/ruby

$ cat app/views/helloworld/index.html.erb
<h1>Helloworld#index</h1>
Rails with mod_rails
<p>Find me in app/views/helloworld/index.html.erb</p>


$ curl "http://localhost/helloworld"
<h1>Helloworld#index</h1>
Rails with mod_rails
<p>Find me in app/views/helloworld/index.html.erb</p>

Apache Bench
$  ab -n 10000 -c 100  "http://localhost/helloworld"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (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
Finished 10000 requests


Server Software:        Apache/2.2.9
Server Hostname:        localhost
Server Port:            80

Document Path:          /helloworld
Document Length:        101 bytes

Concurrency Level:      100
Time taken for tests:   56.952122 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      7000001 bytes
HTML transferred:       1010000 bytes
Requests per second:    175.59 [#/sec] (mean)
Time per request:       569.521 [ms] (mean)
Time per request:       5.695 [ms] (mean, across all concurrent requests)
Transfer rate:          120.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   5.1      0      70
Processing:    50  565 716.6    490   14510
Waiting:       40  562 706.0    490   14510
Total:        110  566 716.5    490   14510

Percentage of the requests served within a certain time (ms)
  50%    490
  66%    510
  75%    520
  80%    530
  90%    610
  95%   1030
  98%   1160
  99%   1610
 100%  14510 (longest request)


メモリの使用状況
top - 17:34:30 up 20 min,  2 users,  load average: 6.34, 6.10, 4.26
Tasks:  72 total,   8 running,  64 sleeping,   0 stopped,   0 zombie
Cpu(s): 82.7%us, 15.2%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  2.2%si,  0.0%st
Mem:    256400k total,   253792k used,     2608k free,      540k buffers
Swap:   524280k total,    18708k used,   505572k free,    21388k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 3041 suzu      25   0 45680  31m 1584 R 10.9 12.5   0:23.41 ruby
 3043 suzu      25   0 45680  31m 1584 R 14.5 12.5   0:23.71 ruby
 3045 suzu      25   0 45680  31m 1584 R 14.5 12.5   0:23.43 ruby
 3049 suzu      25   0 45680  31m 1584 R 13.0 12.5   0:23.48 ruby
 3047 suzu      25   0 45668  31m 1584 R 10.9 12.5   0:23.12 ruby
 3051 suzu      25   0 45676  31m 1584 R 14.5 12.5   0:23.31 ruby
 3039 suzu      20   0 32712  18m 1016 S  0.0  7.3   0:00.72 ruby
 3008 root      15   0 32708  13m 1916 S  0.0  5.2   0:03.58 ruby
 3078 suzu      15   0  8844 3252 1676 S  5.4  1.3   0:01.63 ab
 2756 root      15   0 12988 2216 1756 S  0.0  0.9   0:00.98 httpd
 2710 suzu      15   0  6440 2072 1296 S  0.0  0.8   0:00.89 bash
 3055 apache    15   0 12988 1888 1288 S  0.4  0.7   0:00.85 httpd
 3057 apache    15   0 12988 1888 1288 S  0.7  0.7   0:00.82 httpd
 3058 apache    15   0 12988 1888 1288 S  1.1  0.7   0:00.75 httpd
 3061 apache    16   0 12988 1888 1288 S  0.4  0.7   0:00.81 httpd
 3063 apache    15   0 12988 1888 1288 S  0.0  0.7   0:00.73 httpd
 3064 apache    15   0 12988 1888 1288 S  0.7  0.7   0:00.74 httpd
 3069 apache    15   0 12988 1888 1288 S  1.1  0.7   0:00.82 httpd
 3070 apache    15   0 12988 1888 1288 S  0.7  0.7   0:00.80 httpd
 3071 apache    15   0 12988 1888 1288 S  0.7  0.7   0:00.75 httpd
 3076 apache    15   0 12988 1888 1288 S  0.4  0.7   0:00.55 httpd
 3079 apache    15   0 12988 1888 1288 S  0.0  0.7   0:00.17 httpd
 3011 apache    15   0 12988 1884 1288 S  1.1  0.7   0:00.97 httpd
 3012 apache    15   0 12988 1884 1288 S  1.1  0.7   0:01.08 httpd
 3018 apache    15   0 12988 1884 1288 S  0.0  0.7   0:00.76 httpd
 3023 apache    16   0 12988 1884 1288 S  0.7  0.7   0:00.85 httpd
 3024 apache    15   0 12988 1884 1288 S  1.1  0.7   0:01.07 httpd
 3026 apache    15   0 12988 1884 1288 S  0.0  0.7   0:00.76 httpd
 3029 apache    15   0 12988 1884 1288 S  2.5  0.7   0:00.98 httpd
 2999 apache    15   0 12988 1848 1288 S  0.4  0.7   0:00.97 httpd
 3009 apache    15   0 12988 1836 1288 S  1.1  0.7   0:00.82 httpd

このアーカイブについて

このページには、過去に書かれたブログ記事のうちApache Benchカテゴリに属しているものが含まれています。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。