php框架QPS测试

硬件

操作系统

➜  ~ lsb_release -a
LSB Version:    core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial

cpu

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 79
model name  : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
stepping    : 1
microcode   : 0x1
cpu MHz     : 2499.996
cache size  : 40960 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips    : 4999.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 79
model name  : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
stepping    : 1
microcode   : 0x1
cpu MHz     : 2499.996
cache size  : 40960 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips    : 4999.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

Laravel

Laravel根本跑不动 -n 500000 所以我减少了10倍

➜  laravel57 ab -c 100 -n 50000 http://127.0.0.1:8089/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests

Server Software:        nginx
Server Hostname:        127.0.0.1
Server Port:            8089

Document Path:          /
Document Length:        2321 bytes

Concurrency Level:      100
Time taken for tests:   670.162 seconds
Complete requests:      50000
Failed requests:        0
Total transferred:      164556276 bytes
HTML transferred:       116050000 bytes
Requests per second:    74.61 [#/sec] (mean)
Time per request:       1340.323 [ms] (mean)
Time per request:       13.403 [ms] (mean, across all concurrent requests)
Transfer rate:          239.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       4
Processing:     8 1337 962.2    969    8165
Waiting:        8 1336 962.2    969    8165
Total:         12 1337 962.2    969    8165

Percentage of the requests served within a certain time (ms)
  50%    969
  66%   1508
  75%   1976
  80%   2246
  90%   2744
  95%   3191
  98%   3676
  99%   3993
 100%   8165 (longest request)

lumen

load 5 3.5 1.7

虽说整个过程很坚信,cpu直接吃满..但是还是出结果了

ab测试

➜  sites-available ab -c 100 -n 500000 http://127.0.0.1:8088/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 50000 requests
Completed 100000 requests
Completed 150000 requests
Completed 200000 requests
Completed 250000 requests
Completed 300000 requests
Completed 350000 requests
Completed 400000 requests
Completed 450000 requests
Completed 500000 requests
Finished 500000 requests

Server Software:        nginx
Server Hostname:        127.0.0.1
Server Port:            8088

Document Path:          /
Document Length:        40 bytes

Concurrency Level:      100
Time taken for tests:   220.532 seconds
Complete requests:      500000
Failed requests:        0
Total transferred:      113500000 bytes
HTML transferred:       20000000 bytes
Requests per second:    2267.24 [#/sec] (mean)
Time per request:       44.106 [ms] (mean)
Time per request:       0.441 [ms] (mean, across all concurrent requests)
Transfer rate:          502.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       6
Processing:     2   44   1.6     44      65
Waiting:        2   44   1.6     44      65
Total:          8   44   1.6     44      65

Percentage of the requests served within a certain time (ms)
  50%     44
  66%     45
  75%     45
  80%     45
  90%     46
  95%     46
  98%     47
  99%     48
 100%     65 (longest request)

swoft

➜  ~ ab -c 100 -n 500000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 50000 requests
Completed 100000 requests
Completed 150000 requests
Completed 200000 requests
Completed 250000 requests
Completed 300000 requests
Completed 350000 requests
Completed 400000 requests
Completed 450000 requests
Completed 500000 requests
Finished 500000 requests

Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /
Document Length:        413 bytes

Concurrency Level:      100
Time taken for tests:   82.449 seconds
Complete requests:      500000
Failed requests:        0
Total transferred:      302000000 bytes
HTML transferred:       206500000 bytes
Requests per second:    6064.34 [#/sec] (mean)
Time per request:       16.490 [ms] (mean)
Time per request:       0.165 [ms] (mean, across all concurrent requests)
Transfer rate:          3577.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0      10
Processing:     3   16   7.7     16     330
Waiting:        1   16   7.7     16     330
Total:          9   16   7.7     16     330

Percentage of the requests served within a certain time (ms)
  50%     16
  66%     16
  75%     16
  80%     16
  90%     16
  95%     16
  98%     17
  99%     19
 100%    330 (longest request)

easyswoole

➜  ~ ab -c 100 -n 500000 http://127.0.0.1:9501/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 50000 requests
Completed 100000 requests
Completed 150000 requests
Completed 200000 requests
Completed 250000 requests
Completed 300000 requests
Completed 350000 requests
Completed 400000 requests
Completed 450000 requests
Completed 500000 requests
Finished 500000 requests

Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        373 bytes

Concurrency Level:      100
Time taken for tests:   48.485 seconds
Complete requests:      500000
Failed requests:        0
Total transferred:      271500000 bytes
HTML transferred:       186500000 bytes
Requests per second:    10312.49 [#/sec] (mean)
Time per request:       9.697 [ms] (mean)
Time per request:       0.097 [ms] (mean, across all concurrent requests)
Transfer rate:          5468.44 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3   1.0      4      10
Processing:     1    6   1.6      6      50
Waiting:        0    5   1.6      5      49
Total:          1   10   1.6     10      52
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%     10
  66%     10
  75%     10
  80%     11
  90%     11
  95%     12
  98%     13
  99%     15
 100%     52 (longest request)