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

mod_pythonの最近のブログ記事


 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 は、最下位となりました。





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

このアーカイブについて

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

前のカテゴリはinstallです。

次のカテゴリはmod_wsgiです。

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