PHP7が出てから、pythonより早いというような、記事を良く見ます。
どれもcliでのテストだったので、Apache経由のフレームワーク込みでテストした場合どうなのか、ベンチテストしてみました。
環境
ventualbox:CentOS7
Apache:
Server version: Apache/2.4.6 (CentOS)
Server built: Aug 24 2015 18:11:25
MySQL:
mysql Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using EditLine wrapper
プログラム
mysqlから簡単なデータを取得するだけのプログラムです。
django1.9 |
symfony3 |
$ curl http://localhost:8086/
Hello World! django
django1.9
|
$ curl http://localhost:8085/
Hello World!
symfony3
|
$ ab -c 10 -n 1000 http://localhost:8086/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.4.6
Server Hostname: localhost
Server Port: 8086
Document Path: /
Document Length: 43 bytes
Concurrency Level: 10
Time taken for tests: 3.607 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 267120 bytes
HTML transferred: 43000 bytes
Requests per second: 277.25 [#/sec] (mean)
Time per request: 36.069 [ms] (mean)
Time per request: 3.607 [ms] (mean, across all concurrent requests)
Transfer rate: 72.32 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 4 36 20.7 34 128
Waiting: 4 35 19.8 33 122
Total: 4 36 20.7 34 128
Percentage of the requests served within a certain time (ms)
50% 34
66% 44
75% 50
80% 53
90% 64
95% 73
98% 81
99% 91
100% 128 (longest request)
|
$ ab -c 10 -n 1000 http://localhost:8085/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.4.6
Server Hostname: localhost
Server Port: 8085
Document Path: /
Document Length: 34 bytes
Concurrency Level: 10
Time taken for tests: 51.468 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 333000 bytes
HTML transferred: 34000 bytes
Requests per second: 19.43 [#/sec] (mean)
Time per request: 514.676 [ms] (mean)
Time per request: 51.468 [ms] (mean, across all concurrent requests)
Transfer rate: 6.32 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 244 514 89.2 508 1111
Waiting: 244 513 89.4 507 1111
Total: 244 514 89.2 508 1111
Percentage of the requests served within a certain time (ms)
50% 508
66% 540
75% 562
80% 575
90% 607
95% 640
98% 670
99% 712
100% 1111 (longest request)
|
結果、djangoが圧勝でした。
おそらく、他に早いフレームワークが・・という声もあるはずです。
時間があれば、他のフレームワークも試してみたいと思います。