一、环境介绍

  • 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. Storm 开箱笔记

    目录 Storm 开箱 1. 什么是 Storm 2. Hello World(WordCountTopology) 3. 常用API 4. 基本概念 5. 流分组策略 6. 并行度 7. Acker ...

  2. Python学习第二阶段,day1, 装饰器,生成器,迭代器

    装饰器 不得不说,这是对初学者最难以理解的概念了,虽然我学过面向对象,但还是被搞懵逼了..前面还好理解,主要是后面“装饰器的装饰器”我理解不了.装饰器工厂,根据传入的参数不同去返回不同的装饰器,我不得 ...

  3. 来说一说chrome扩展和chrome插件到底有什么区别?

    想讨论chrome扩展和chrome插件区别这个话题很久了!但是迟迟没有写.因为我自己也没有搞清楚这两者之间的区别!回想当初是因为需要寻找番羽墙插件才想到去搜索到chrome插件. 想讨论chrome ...

  4. mac下Redis安装和使用

    前言 本篇文章主要讲述了Mac下Redis的安装和使用的经验,并将python如何操作Redis做了简单介绍. 1. redis 安装 和启动 1.1 用brew安装 查看系统是否已经安装了Redis ...

  5. angular中多个promise的合并处理

    all()方法 这个all()方法,可以把多个primise的数组合并成一个.当所有的promise执行成功后,会执行后面的回调.回调中的参数,是每个promise执行的结果.当批量的执行某些方法时, ...

  6. Vue2.0如何自定义时间过滤器

    我们知道Vue2.0开始不再支持自带的过滤器,需要我们自己去自定义过滤器,方法如下:           我们可以自己定义一个时间过滤器,在此引用了一个日期处理类库(Moment.js)可以很快的实现 ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. POJ 1226 Substrings

    Substrings Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: ...

  9. eclipse编译项目用maven编译问题

    1.eclipse只是个ide开发环境,并没有编译器功能.没有编译器.eclipse编译项目只是调jdk本地的java编译器.maven是单独编译,eclipse可以调用maven编译, 在eclip ...

  10. 战术网络安全检查表 | Symantec Connect

    "知己知彼,百战不殆: 不知彼而知己,一胜一负: 不知彼,不知己,每战必殆." 孙子(中国古代军事家). 孙子的话在今日仍能够使我们产生共鸣. 机构只有了解敌人和自己优缺点才能在持 ...