美文网首页
测试一下nginx+php-fpm和swoole http服务器

测试一下nginx+php-fpm和swoole http服务器

作者: 键盘上行走的农民 | 来源:发表于2018-01-21 21:09 被阅读0次

    服务器vm虚拟机 1核1G

     环境 :nginx/1.13.8  +    php7.2.1 + mysql 5.7.2

    环境 :swoole 2.0.12

    这是nginx的默认html页 3900 

    ab -c 150 -n 100000 http://192.168.11.109/

    This is ApacheBench, Version 2.3 <$Revision: 1748469 $>

    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 192.168.11.109 (be patient)

    Server Software:        nginx/1.13.8

    Server Hostname:        192.168.11.109

    Server Port:            80

    Document Path:          /

    Document Length:        612 bytes

    Concurrency Level:      150

    Time taken for tests:  25.640 seconds

    Complete requests:      100000

    Failed requests:        0

    Total transferred:      84500000 bytes

    HTML transferred:      61200000 bytes

    Requests per second:    3900.15 [#/sec] (mean)

    Time per request:      38.460 [ms] (mean)

    Time per request:      0.256 [ms] (mean, across all concurrent requests)

    Transfer rate:          3218.38 [Kbytes/sec] received

    Connection Times (ms)

                  min  mean[+/-sd] median  max

    Connect:        0    4  66.9      0    3069

    Processing:    5  33  50.4    32    7675

    Waiting:        5  33  50.4    32    7674

    Total:        12  37  88.0    32    7678

    Percentage of the requests served within a certain time (ms)

      50%    32

      66%    32

      75%    33

      80%    33

      90%    34

      95%    36

      98%    44

      99%    50

     100%  7678 (longest request)

    php-fpm 原生 

     ab -c 150 -n 100000 http://192.168.11.109/hello.php

    This is ApacheBench, Version 2.3 <$Revision: 1748469 $>

    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 192.168.11.109 (be patient)

    Completed 10000 requests

    Completed 20000 requests

    Completed 30000 requests

    Completed 40000 requests

    Completed 50000 requests

    Completed 60000 requests

    Completed 70000 requests

    Completed 80000 requests

    Completed 90000 requests

    Completed 100000 requests

    Finished 100000 requests

    Server Software:        nginx/1.13.8

    Server Hostname:        192.168.11.109

    Server Port:            80

    Document Path:          /hello.php

    Document Length:        11 bytes

    Concurrency Level:      150

    Time taken for tests:  45.074 seconds

    Complete requests:      100000

    Failed requests:        0

    Total transferred:      17300000 bytes

    HTML transferred:      1100000 bytes

    Requests per second:    2218.58 [#/sec] (mean)

    Time per request:      67.611 [ms] (mean)

    Time per request:      0.451 [ms] (mean, across all concurrent requests)

    Transfer rate:          374.82 [Kbytes/sec] received

    Connection Times (ms)

                  min  mean[+/-sd] median  max

    Connect:        0    0  0.3      0      10

    Processing:    34  66  94.8    59    3082

    Waiting:      34  66  94.8    59    3082

    Total:        36  66  94.8    60    3082

    Percentage of the requests served within a certain time (ms)

      50%    60

      66%    62

      75%    64

      80%    66

      90%    70

      95%    74

      98%    86

      99%    254

     100%  3082 (longest request)

    swoole 同步http输出Hello word!

    ab -c 150 -n 100000 http://192.168.11.109:9501/

    This is ApacheBench, Version 2.3 <$Revision: 1748469 $>

    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 192.168.11.109 (be patient)

    Completed 10000 requests

    Completed 20000 requests

    Completed 30000 requests

    Completed 40000 requests

    Completed 50000 requests

    Completed 60000 requests

    Completed 70000 requests

    Completed 80000 requests

    Completed 90000 requests

    Completed 100000 requests

    Finished 100000 requests

    Server Software:        swoole-http-server

    Server Hostname:        192.168.11.109

    Server Port:            9501

    Document Path:          /

    Document Length:        11 bytes

    Concurrency Level:      150

    Time taken for tests:  23.467 seconds

    Complete requests:      100000

    Failed requests:        0

    Total transferred:      15900000 bytes

    HTML transferred:      1100000 bytes

    Requests per second:    4261.30 [#/sec] (mean)

    Time per request:      35.201 [ms] (mean)

    Time per request:      0.235 [ms] (mean, across all concurrent requests)

    Transfer rate:          661.67 [Kbytes/sec] received

    Connection Times (ms)

                  min  mean[+/-sd] median  max

    Connect:        0    1  3.7      0    135

    Processing:    5  35  16.6    32    204

    Waiting:        4  34  16.6    32    204

    Total:          7  35  17.6    32    216

    Percentage of the requests served within a certain time (ms)

      50%    32

      66%    35

      75%    40

      80%    41

      90%    44

      95%    46

      98%    50

      99%    121

     100%    216 (longest request)

    liuxuns-MacBook-Pro:~ liuxun$ ab -c 150 -n 100000 http://192.168.11.109:9501/

    This is ApacheBench, Version 2.3 <$Revision: 1748469 $>

    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 192.168.11.109 (be patient)

    Completed 10000 requests

    Completed 20000 requests

    Completed 30000 requests

    Completed 40000 requests

    Completed 50000 requests

    Completed 60000 requests

    Completed 70000 requests

    Completed 80000 requests

    Completed 90000 requests

    Completed 100000 requests

    Finished 100000 requests

    Server Software:        swoole-http-server

    Server Hostname:        192.168.11.109

    Server Port:            9501

    Document Path:          /

    Document Length:        11 bytes

    Concurrency Level:      150

    Time taken for tests:  23.927 seconds

    Complete requests:      100000

    Failed requests:        0

    Total transferred:      15900000 bytes

    HTML transferred:      1100000 bytes

    Requests per second:    4179.29 [#/sec] (mean)

    Time per request:      35.891 [ms] (mean)

    Time per request:      0.239 [ms] (mean, across all concurrent requests)

    Transfer rate:          648.93 [Kbytes/sec] received

    Connection Times (ms)

                  min  mean[+/-sd] median  max

    Connect:        0    0  3.5      0    107

    Processing:    4  35  19.5    31    207

    Waiting:        4  35  19.5    31    207

    Total:          6  36  20.5    31    218

    Percentage of the requests served within a certain time (ms)

      50%    31

      66%    36

      75%    43

      80%    44

      90%    48

      95%    50

      98%    60

      99%    184

     100%    218 (longest request)

    因为swoole 是常驻内存处理简单的php 和nginx处理静态html差不多 

    但swoole cpu站用60%左右  nginx cpu占用80%左右。

    下步测试一下 几个php框架在nginx+php-fpm下的性能

    相关文章

      网友评论

          本文标题:测试一下nginx+php-fpm和swoole http服务器

          本文链接:https://www.haomeiwen.com/subject/fnvqaxtx.html