『Django Ver.1 + mod_wsgi で "Hello, world!" 』で用意したもので確認します。
ApacheのConfファイル
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/"Apache Bench
Hello, world. Django with mod_wsgi
$ 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
For a pure speed test, results are incorrectly counting in time to load up Django the first time. This is why your maximum request time is so large (5 seconds). Because you have done a large number of requests the impact of this will be reduced as averaged over all requests, but still best to eliminate it. To do this either prime Apache/mod_wsgi by running test and then running it a second time and use results of second test. Or configure mod_wsgi to preload WSGI script when processes are started by Apache and not when the WSGI script is loaded for the first request. Latter done by adding:
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /home/httpd/vhost/django/django_with_wsgi/apache/django.wsgi process-group={GLOBAL} application-group=%{GLOBAL}
No I don't know Japanese. Google translate service is my friend.
Thank you very much for useful good advice.
This investigation could last around 10 times and performed Apache Bench
and chose a good thing in that.
However, the environment that I inspected was not good and performed it
with the low PC of specifications.
I fix slightly good environment this time.
And I test Apache Bench by setting of Apache Conf which you taught me.
Me too. No I don't know English. "honyaku(translate) service" of Google
and Yahoo is my friend.
----
Graham Dumpletonさん
役に立つ良いアドバイスをどうも有難うございます。
今回の調査は、10回ぐらい続けてApache Benchを行い、そのなかでも良いものを選びました。
しかし、検証した環境はよくなく、スペックの低いパソコンで行ったのです。
そのため、Graham Dumpletonさんが思ってたよりも良くない内容だったと思います。
次は少しだけ良い環境を整えます。
そして、教えて頂いた Apache Confの 設定で Apache Bench を試してみたいと思います。
私は英語が得意ではなく、翻訳サイトなどを駆使して返信しました。