zoukankan      html  css  js  c++  java
  • 关于swoole 和golang 的压力测试结果

    一、环境介绍

    • linux centos7
    • php7.1.18
    • go1.12.1
    • 2核4G内存

    二、代码

    • swoole代码
    <?php
    $http = new swoole_http_server("127.0.0.1", 9501);
    
    $http->on("start", function ($server) {
        echo "Swoole http server is started at http://127.0.0.1:9501
    ";
    });
    
    $http->on("request", function ($request, $response) {
        $response->header("Content-Type", "text/html");
        $response->end("Hello World
    ");
    });
    
    $http->start();
    
    • golang 代码
    package main
    import (
        "io"
        "net/http"
    )
    func main() {
        http.ListenAndServe("0.0.0.0:9502", http.HandlerFunc(handle))
    }
    func handle(rw http.ResponseWriter, r *http.Request) {
        rw.Header().Set("Content-Type", "text/html")
        io.WriteString(rw, "Hello World
    ")
    }
    

    三、开始测试

    3.1 ab -n 100 -c 10

    swoole

    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      10
    Time taken for tests:   0.014 seconds
    Complete requests:      100
    Failed requests:        0
    Write errors:           0
    Total transferred:      16000 bytes
    HTML transferred:       1200 bytes
    Requests per second:    6957.01 [#/sec] (mean)
    Time per request:       1.437 [ms] (mean)
    Time per request:       0.144 [ms] (mean, across all concurrent requests)
    Transfer rate:          1087.03 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    0   0.1      0       1
    Processing:     0    1   0.3      1       2
    Waiting:        0    1   0.2      1       1
    Total:          1    1   0.3      1       2
    
    Percentage of the requests served within a certain time (ms)
      50%      1
      66%      1
      75%      1
      80%      2
      90%      2
      95%      2
      98%      2
      99%      2
     100%      2 (longest request)
    

    golang

    Server Software:
    Server Hostname:        127.0.0.1
    Server Port:            9502
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      10
    Time taken for tests:   0.021 seconds
    Complete requests:      100
    Failed requests:        0
    Write errors:           0
    Total transferred:      11300 bytes
    HTML transferred:       1200 bytes
    Requests per second:    4760.54 [#/sec] (mean)
    Time per request:       2.101 [ms] (mean)
    Time per request:       0.210 [ms] (mean, across all concurrent requests)
    Transfer rate:          525.33 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    0   0.2      0       1
    Processing:     0    1   0.8      1       8
    Waiting:        0    1   0.7      1       7
    Total:          0    1   0.8      1       8
    
    Percentage of the requests served within a certain time (ms)
      50%      1
      66%      2
      75%      2
      80%      2
      90%      2
      95%      2
      98%      2
      99%      8
     100%      8 (longest request)
    

    3.2 ab -n 1000 -c 100

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      100
    Time taken for tests:   0.094 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      160000 bytes
    HTML transferred:       12000 bytes
    Requests per second:    10680.68 [#/sec] (mean)
    Time per request:       9.363 [ms] (mean)
    Time per request:       0.094 [ms] (mean, across all concurrent requests)
    Transfer rate:          1668.86 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    2   1.2      2       6
    Processing:     2    7   3.0      6      14
    Waiting:        0    6   2.5      5      13
    Total:          4    9   2.9      8      18
    
    Percentage of the requests served within a certain time (ms)
      50%      8
      66%      9
      75%     10
      80%     11
      90%     13
      95%     14
      98%     17
      99%     17
     100%     18 (longest request)
    

    golang

    Server Software:
    Server Hostname:        127.0.0.1
    Server Port:            9502
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      100
    Time taken for tests:   0.107 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      113000 bytes
    HTML transferred:       12000 bytes
    Requests per second:    9331.75 [#/sec] (mean)
    Time per request:       10.716 [ms] (mean)
    Time per request:       0.107 [ms] (mean, across all concurrent requests)
    Transfer rate:          1029.77 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    1   1.4      1       6
    Processing:     1    9   5.3      8      35
    Waiting:        0    8   5.0      7      34
    Total:          1   10   4.9      9      38
    
    Percentage of the requests served within a certain time (ms)
      50%      9
      66%     11
      75%     13
      80%     14
      90%     17
      95%     18
      98%     20
      99%     25
     100%     38 (longest request)
    

    3.3 ab -n 10000 -c 1000

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      1000
    Time taken for tests:   0.868 seconds
    Complete requests:      10000
    Failed requests:        0
    Write errors:           0
    Total transferred:      1600000 bytes
    HTML transferred:       120000 bytes
    Requests per second:    11515.25 [#/sec] (mean)
    Time per request:       86.841 [ms] (mean)
    Time per request:       0.087 [ms] (mean, across all concurrent requests)
    Transfer rate:          1799.26 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    4   4.7      3      30
    Processing:     3   11   5.0     10     216
    Waiting:        0    9   4.7      9     214
    Total:          6   15   7.1     14     239
    
    Percentage of the requests served within a certain time (ms)
      50%     14
      66%     15
      75%     16
      80%     17
      90%     20
      95%     26
      98%     41
      99%     42
     100%    239 (longest request)
    

    golang

    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      1000
    Time taken for tests:   1.018 seconds
    Complete requests:      10000
    Failed requests:        0
    Write errors:           0
    Total transferred:      1130000 bytes
    HTML transferred:       120000 bytes
    Requests per second:    9823.25 [#/sec] (mean)
    Time per request:       101.799 [ms] (mean)
    Time per request:       0.102 [ms] (mean, across all concurrent requests)
    Transfer rate:          1084.01 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    5   6.6      3      37
    Processing:     0   13   9.3     12     209
    Waiting:        0   11   8.2     10     205
    Total:          0   18  13.5     15     210
    
    Percentage of the requests served within a certain time (ms)
      50%     15
      66%     17
      75%     19
      80%     21
      90%     33
      95%     45
      98%     66
      99%     77
     100%    210 (longest request)
    

    3.4 ab -n 100000 -c 10000

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      10000
    Time taken for tests:   9.582 seconds
    Complete requests:      100000
    Failed requests:        0
    Write errors:           0
    Total transferred:      16000000 bytes
    HTML transferred:       1200000 bytes
    Requests per second:    10436.61 [#/sec] (mean)
    Time per request:       958.166 [ms] (mean)
    Time per request:       0.096 [ms] (mean, across all concurrent requests)
    Transfer rate:          1630.72 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  487 535.1    297    7133
    Processing:    62  374 115.8    388     832
    Waiting:        0  286  96.7    273     704
    Total:        161  861 549.7    696    7350
    
    Percentage of the requests served within a certain time (ms)
      50%    696
      66%    826
      75%    912
      80%   1225
      90%   1607
      95%   1739
      98%   2005
      99%   3442
     100%   7350 (longest request)
    

    golang

    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      10000
    Time taken for tests:   16.700 seconds
    Complete requests:      100000
    Failed requests:        0
    Write errors:           0
    Total transferred:      11300000 bytes
    HTML transferred:       1200000 bytes
    Requests per second:    5987.91 [#/sec] (mean)
    Time per request:       1670.033 [ms] (mean)
    Time per request:       0.167 [ms] (mean, across all concurrent requests)
    Transfer rate:          660.77 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  709 1278.7     20    7048
    Processing:     0   72 324.6     34   13554
    Waiting:        0   66 324.3     27   13553
    Total:          1  781 1357.7     64   16588
    
    Percentage of the requests served within a certain time (ms)
      50%     64
      66%   1029
      75%   1047
      80%   1061
      90%   3041
      95%   3091
      98%   7041
      99%   7083
     100%  16588 (longest request)
    

    3.5 ab -n 200000 -c 20000

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      20000
    Time taken for tests:   20.057 seconds
    Complete requests:      200000
    Failed requests:        0
    Write errors:           0
    Total transferred:      32000000 bytes
    HTML transferred:       2400000 bytes
    Requests per second:    9971.56 [#/sec] (mean)
    Time per request:       2005.704 [ms] (mean)
    Time per request:       0.100 [ms] (mean, across all concurrent requests)
    Transfer rate:          1558.06 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  913 689.1    696   15748
    Processing:   324  966 229.3    959    1970
    Waiting:        0  736 189.6    743    1556
    Total:        909 1879 716.9   1659   16114
    
    Percentage of the requests served within a certain time (ms)
      50%   1659
      66%   1842
      75%   2129
      80%   2427
      90%   2605
      95%   2744
      98%   4279
      99%   4522
     100%  16114 (longest request)
    

    golang

    Server Software:
    Server Hostname:        127.0.0.1
    Server Port:            9502
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      20000
    Time taken for tests:   34.083 seconds
    Complete requests:      200000
    Failed requests:        0
    Write errors:           0
    Total transferred:      22600000 bytes
    HTML transferred:       2400000 bytes
    Requests per second:    5868.07 [#/sec] (mean)
    Time per request:       3408.274 [ms] (mean)
    Time per request:       0.170 [ms] (mean, across all concurrent requests)
    Transfer rate:          647.55 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0 1328 2378.8    466   15093
    Processing:     0  171 1106.5     44   26576
    Waiting:        0  163 1106.7     37   26573
    Total:          0 1499 2775.8    709   33626
    
    Percentage of the requests served within a certain time (ms)
      50%    709
      66%   1069
      75%   1190
      80%   3031
      90%   3209
      95%   7080
      98%   8709
      99%  15161
     100%  33626 (longest request)
    

    3.6 ab -n 300000 -c 20000

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      20000
    Time taken for tests:   29.131 seconds
    Complete requests:      300000
    Failed requests:        0
    Write errors:           0
    Total transferred:      48000000 bytes
    HTML transferred:       3600000 bytes
    Requests per second:    10298.19 [#/sec] (mean)
    Time per request:       1942.089 [ms] (mean)
    Time per request:       0.097 [ms] (mean, across all concurrent requests)
    Transfer rate:          1609.09 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  944 887.3    691   15919
    Processing:   294  938 220.0    923    2056
    Waiting:        0  743 203.4    717    1877
    Total:        725 1882 922.0   1665   16908
    
    Percentage of the requests served within a certain time (ms)
      50%   1665
      66%   1843
      75%   2125
      80%   2263
      90%   2641
      95%   2994
      98%   4552
      99%   4814
     100%  16908 (longest request)
    

    golang

    已无法承受压力
    

    3.7 ab -n 400000 -c 20000

    swoole

    Server Software:        swoole-http-server
    Server Hostname:        127.0.0.1
    Server Port:            9501
    
    Document Path:          /
    Document Length:        12 bytes
    
    Concurrency Level:      20000
    Time taken for tests:   39.223 seconds
    Complete requests:      400000
    Failed requests:        0
    Write errors:           0
    Total transferred:      64000000 bytes
    HTML transferred:       4800000 bytes
    Requests per second:    10197.99 [#/sec] (mean)
    Time per request:       1961.170 [ms] (mean)
    Time per request:       0.098 [ms] (mean, across all concurrent requests)
    Transfer rate:          1593.44 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0  930 717.2    722   15587
    Processing:   360  975 198.0    962    2555
    Waiting:        0  738 168.0    739    2344
    Total:        740 1905 740.7   1732   16800
    
    Percentage of the requests served within a certain time (ms)
      50%   1732
      66%   1894
      75%   2015
      80%   2263
      90%   2623
      95%   2836
      98%   4397
      99%   4623
     100%  16800 (longest request)
    

    golang

    已无法承受压力
    
  • 相关阅读:
    Modbus RTU与Modbus TCP的区别
    《对比Excel,轻松学习Python数据分析》笔记
    字符串 批量删除
    地图服务在线资源
    Java环境变量配置及maven配置
    Android学习路线
    MySQL备份脚本,应该这么写
    Windows中mysql5.6升级5.7
    SQL Server数据分析面试题(202008)
    PYTHON-未知错误
  • 原文地址:https://www.cnblogs.com/xiaobaiskill/p/10931789.html
Copyright © 2011-2022 走看看