一、环境介绍

  • 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\n";
}); $http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/html");
$response->end("Hello World\n");
}); $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\n")
}

三、开始测试

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

已无法承受压力

关于swoole 和golang 的压力测试结果的更多相关文章

  1. Golang 语言的单元测试和性能测试(也叫 压力测试)

    Golang单元测试对文件名和方法名,参数都有很严格的要求. 例如: 1.文件名必须以xx_test.go命名 2.方法必须是Test[^a-z]开头(T必须大写),func TestXxx (t * ...

  2. centos7.5 ab压力测试安装和swoole压力测试

    Apache Benchmark(简称ab) 是Apache安装包中自带的压力测试工具 ,简单易用 1.ab安装 yum -y install httpd-tools 2.ab参数详解,传送门:htt ...

  3. 开源API集成测试工具 Hitchhiker v0.2更新 - 压力测试

    Hitchhiker 是一款开源的 Restful Api 集成测试工具,支持Schedule, 数据对比,压力测试,可以轻松部署到本地,和你的team成员一起管理Api. 详细介绍请看: http: ...

  4. 使用 WRK 压力测试工具对 ASP.NET Core 的接口进行压力测试

    0. 简要介绍 WRK 是一款轻量且易用的 HTTP 压力测试工具,通过该工具我们可以方便地对我们所开发的 WebAPI 项目进行压力测试,并且针对测试的情况返回结果. PS:Wrk 并不能针对测试的 ...

  5. 在Centos下使用Siege对Django服务进行压力测试

    Siege是linux下的一个web系统的压力测试工具,支持多链接,支持get和post请求,可以对web系统进行多并发下持续请求的压力测试.今天我们就使用Siege来对Django进行一次压力测试, ...

  6. 在Centos7.3下使用Siege对Django服务进行压力测试

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_87 Siege是linux下的一个web系统的压力测试工具,支持多链接,支持get和post请求,可以对web系统进行多并发下持续 ...

  7. 使用SwingBench 对Oracle RAC DB性能 压力测试

    我们可以使用swingbench这个工具对数据库性能进行压力测试,得到一些性能指标作为参考. SwingBench下载: http://www.dominicgiles.com/downloads.h ...

  8. linux压力测试工具stress

    最近给PASS平台添加autoscaling的功能,根据服务器的负载情况autoscaling,为了测试这项功能用到了stress这个压力测试工具,这个工具相当好用了.具体安装方式就不说了.记录下这个 ...

  9. JMeter压力测试

    Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试但后来扩展到其他测试领域. 它可以用于测试静态和动态资源例如静态文件. ...

随机推荐

  1. React组件设计技巧

    React组件设计 组件分类 展示组件和容器组件 展示组件 容器组件 关注事物的展示 关注事物如何工作 可能包含展示和容器组件,并且一般会有DOM标签和css样式 可能包含展示和容器组件,并且不会有D ...

  2. airfoil polar data during post stall stages (high AOA)

    airfoil polar data during post stall stages (high AOA) Table of Contents 1. airfoil polar during pos ...

  3. Boundary Conditions

    test test Table of Contents 1. Boundary conditions 1.1. Neumann boudary condition vs Dirichlet BC 1. ...

  4. 【Codeforces 1038D】Slime

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 相当于让你确定每个数字前面的系数是-1还是+1 有个结论是这样每次和相邻的减的话, 任何出除了全"-1"和全"+ ...

  5. Oracle学习总结(4)——MySql、SqlServer、Oracle数据库行转列大全

    MySql行转列 以id分组,把name字段的值打印在一行,逗号分隔(默认) select CustomerDrugCode,group_concat(AuditItemName) from noau ...

  6. nyoj 1112 求次数(map, set)

    求次数 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 题意很简单,给一个数n 以及一个字符串str,区间[i,i+n-1] 为一个新的字符串,i 属于[0,strl ...

  7. [luoguP2858] [USACO06FEB]奶牛零食Treats for the Cows(DP)

    传送门 f[i][j][k] 表示 左右两段取到 i .... j 时,取 k 次的最优解 可以优化 k 其实等于 n - j + i 则 f[i][j] = max(f[i + 1][j] + a[ ...

  8. NYOJ5 Binary String Matching

    Binary String Matching 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 Given two strings A and B, whose alp ...

  9. P1516 青蛙的约会 洛谷

    https://www.luogu.org/problem/show?pid=1516 题目描述 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上, ...

  10. Mac OS忘记password怎么办?无光盘破解Mac OS的管理员password

    mac系统10.8.5升级10.10 出现故障,重新启动系统无法登陆,降级系统10.9 后更新10.9.3 finder无法打开,root权限没了,又再一次覆盖安装10.9(为了保护原系统文件.所以覆 ...