Comments (4)
我刚在阿里云申请机器(4核4G内存 硬盘是SSD的),压测了一下,QPS都是1.1万以上(go-stress-testing 单核cpu)
这里有压测示例,可以参考一下:
-
简单的修改一下,然后QPS可以达到1.8W, (go-stress-testing 双核cpu),机器性能更高这个数值会更高
-
这里需要让出双核给go-stress-testing使用
代码修改处
# 这里默认设置1,因为设置为1已经可以达到1W多QPS了,一般的环境压测已经够用了
runtime.GOMAXPROCS(2)
- webSevers 使用两核
package main
import (
"log"
"net/http"
"runtime"
)
const (
httpPort = "8088"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU() - 2)
hello := func(w http.ResponseWriter, req *http.Request) {
data := "Hello, go-stress-testing! \n"
w.Header().Add("Server", "golang")
w.Write([]byte(data))
return
}
http.HandleFunc("/", hello)
err := http.ListenAndServe(":"+httpPort, nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
- 压测结果
─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────
耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│ 错误码
─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────
1s│ 50│ 14914│ 0│18934.49│ 9.23│ 0.14│ 0.05│200:14914
2s│ 50│ 29782│ 0│18858.30│ 9.23│ 0.13│ 0.05│200:29782
3s│ 50│ 44707│ 0│18896.09│ 9.23│ 0.13│ 0.05│200:44707
4s│ 50│ 59431│ 0│18855.79│ 9.23│ 0.13│ 0.05│200:59438
5s│ 50│ 74158│ 0│18808.65│ 9.88│ 0.11│ 0.05│200:74158
6s│ 50│ 89118│ 0│18819.66│ 9.88│ 0.11│ 0.05│200:89118
7s│ 50│ 103870│ 0│18817.46│ 9.88│ 0.11│ 0.05│200:103870
8s│ 50│ 118742│ 0│18813.89│ 9.88│ 0.11│ 0.05│200:118742
9s│ 50│ 133466│ 0│18789.33│ 9.88│ 0.11│ 0.05│200:133466
10s│ 50│ 148417│ 0│18792.07│ 9.88│ 0.11│ 0.05│200:148417
11s│ 50│ 163218│ 0│18784.73│ 9.88│ 0.11│ 0.05│200:163218
12s│ 50│ 178074│ 0│18776.90│ 9.88│ 0.11│ 0.05│200:178074
13s│ 50│ 193088│ 0│18789.44│ 10.00│ 0.11│ 0.05│200:193088
14s│ 50│ 208040│ 0│18792.23│ 10.00│ 0.11│ 0.05│200:208040
15s│ 50│ 222913│ 0│18793.01│ 10.00│ 0.11│ 0.05│200:222913
16s│ 50│ 237838│ 0│18797.81│ 10.00│ 0.11│ 0.05│200:237838
17s│ 50│ 252754│ 0│18800.27│ 10.00│ 0.11│ 0.05│200:252754
18s│ 50│ 267747│ 0│18806.46│ 10.00│ 0.11│ 0.05│200:267747
19s│ 50│ 282767│ 0│18810.77│ 10.00│ 0.11│ 0.05│200:282767
20s│ 50│ 297592│ 0│18794.86│ 10.00│ 0.11│ 0.05│200:297592
21s│ 50│ 312306│ 0│18783.67│ 10.00│ 0.11│ 0.05│200:312306
22s│ 50│ 327172│ 0│18787.24│ 10.00│ 0.11│ 0.05│200:327172
23s│ 50│ 341958│ 0│18777.17│ 10.00│ 0.11│ 0.05│200:341958
24s│ 50│ 356835│ 0│18777.52│ 10.00│ 0.11│ 0.05│200:356835
25s│ 50│ 371560│ 0│18768.69│ 10.23│ 0.11│ 0.05│200:371560
26s│ 50│ 386398│ 0│18775.99│ 10.23│ 0.11│ 0.05│200:386398
27s│ 50│ 401230│ 0│18768.21│ 10.23│ 0.11│ 0.05│200:401230
28s│ 50│ 416096│ 0│18759.15│ 10.23│ 0.11│ 0.05│200:416096
29s│ 50│ 430992│ 0│18757.52│ 10.23│ 0.11│ 0.05│200:430992
30s│ 50│ 445942│ 0│18753.45│ 10.23│ 0.11│ 0.05│200:445942
31s│ 50│ 460944│ 0│18763.31│ 10.23│ 0.11│ 0.05│200:460944
32s│ 50│ 475966│ 0│18765.11│ 10.23│ 0.11│ 0.05│200:475966
33s│ 50│ 490832│ 0│18767.78│ 10.23│ 0.11│ 0.05│200:490832
34s│ 50│ 500000│ 0│18818.59│ 10.23│ 0.11│ 0.05│200:500000
- top 结果
Tasks: 121 total, 2 running, 119 sleeping, 0 stopped, 0 zombie
%Cpu(s): 43.9 us, 25.8 sy, 0.0 ni, 20.5 id, 0.0 wa, 1.1 hi, 8.7 si, 0.0 st
MiB Mem : 3777.8 total, 2297.2 free, 265.3 used, 1215.3 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 3285.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4354 root 20 0 1084396 19836 5624 R 170.0 0.5 0:26.91 go-stre+
4239 root 20 0 1157404 18832 5168 S 114.3 0.5 1:48.64 server
from go-stress-testing.
单台机器 4核,压测工具分配一核,http server 分配一核
压测结果是 接近2W QPS
---------------- 2020年 9月13日 星期日 11时14分48秒 CST 补充--------------
单台机器8核机器,压测结果是 4W QPS
from go-stress-testing.
// 平均 QPS 成功数总协程数/总耗时 (每秒)
if processingTime != 0 {
qps = float64(successNumconcurrent) * (1e9 / float64(processingTime))
}
代码中QPS的计算逻辑可以解释一下吗?
from go-stress-testing.
// 平均 QPS 成功数_总协程数/总耗时 (每秒) if processingTime != 0 { qps = float64(successNum_concurrent) * (1e9 / float64(processingTime)) } 代码中QPS的计算逻辑可以解释一下吗?
from go-stress-testing.
Related Issues (20)
- header错误 HOT 3
- Html report HOT 1
- websocket压测并发数上限为1万
- 发起websocket为什么需要暂停?而且暂停时间是1秒写的60秒 HOT 2
- go-stress不能测试get吗 HOT 1
- 可以支持从文件加载body吗?类似ab的-p参数 HOT 1
- websocket 协议没有透传header HOT 2
- 为什么接受数据使用channel接收数据缓存 HOT 1
- 发送http请求收到的body为空 HOT 3
- 支持 http proxy 和 socks5 proxy 吗? HOT 1
- 执行curl文件不能正确加载host HOT 1
- mac 无法安装 HOT 1
- GC相关的问题
- v1.0.6 的 exe 闪退 HOT 1
- 增加龙架构(loong64)的支持 HOT 1
- 溢出bug HOT 1
- mac intel x64 HOT 3
- 工具使用问题 HOT 1
- 如何不限制时长压测 HOT 6
- 可以支持并发多个请求吗 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-stress-testing.