Giter Club home page Giter Club logo

go-stress-testing's Introduction

go-stress-testing's People

Contributors

dependabot[bot] avatar fish-ball avatar future2023922 avatar gowa2017 avatar guowei-gong avatar link1st avatar wuhelong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-stress-testing's Issues

webSocket发送和读取数据

image
求问,这里的数据发送和数据读取为什么要怎么写?
我认为webSocket数据发送和数据读取是平行的。数据不能发送不代表不能接收数据吧?

connectionMode = 2

修改connectionMode = 2 后

connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or es
tablished connection failed because connected host has failed to respond.
exit status 2

我要测试5000个单机效果
创建到1560个websocket 并发测试,就报上面错误了

officially locust package has updated, demo about locust should be updated

in readme.md page, about locust demo should be updated like this, or will throw exception task no found or class no found:

from locust import HttpUser, TaskSet, task

# 定义用户行为
class UserBehavior(TaskSet):

    @task
    def baidu_index(self):
        self.client.get("/")

class WebsiteUser(HttpUser):
    task = [UserBehavior] # 指向一个定义的用户行为类
    min_wait = 3000 # 执行事务之间用户等待时间的下界(单位:毫秒)
    max_wait = 6000 # 执行事务之间用户等待时间的上界(单位:毫秒)

README.md 6.2 内核优化

添加以下参数
root soft nofile 1040000 <- repeat 1
root hard nofile 1040000

root soft nofile 1040000 <- repeat 1
root hard nproc 1040000

root soft core unlimited
root hard core unlimited

  • soft nofile 1040000 <- repeat 2

  • hard nofile 1040000

  • soft nofile 1040000 <- repeat 2

  • hard nproc 1040000

  • soft core unlimited

  • hard core unlimited


两处重复是否正确?

是否应该修改为

root soft nproc 1040000
root hard nproc 1040000

* soft nproc 1040000
* hard nproc 1040000

See error:connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted.

I run the testing like: go-stress-testing-win.exe -c 100 -n 1000 -u http://10.40.5.155:8080 on windows box.
After "成功数" goes up to 65536, it raises error:
connectex: Only one usage of each socket address (protocol/network address/port) is normally permitted.

After add one line to ""server/client/http_client.go" the issue is gone, plz check.
check code here --> req, err := http.NewRequest(method, url, body)
add line-> req.Close = true

是否有计划支持随机参数去压测

从实际工作中,参数都不是固定的,请问是否有考虑支持,我昨天拿着你的代码,简单改了一下支持了随机参数去压测,但是只实现了http的方式的。而且跟现在功能很不兼容,暂时也不好提一个mr过来

如何避免大量TIME_WAIT?

你好,通过go夜读了解到这个项目,想问一下在压测过程中 如何尽量避免大量出现TIME_WAIT?
通过增大超时时间的设置么。

请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address

在同一台机器上测试:
先起服务
go run tests/servers.go

后面测试:

[root@test-10 go-stress-testing]# go run main.go -c 100 -n 10000 -u http://127.0.0.1:8088/

开始启动 并发数:100 请求数:10000 请求参数:
request:
form:http
url:http://127.0.0.1:8088/
method:GET
headers:map[]
data:
verify:statusCode
timeout:30s
debug:false

─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────
耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│ 错误码
─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────
1s│ 100│ 4846│ 0│ 6372.45│ 40.35│ 1.25│ 15.69│200:4846
2s│ 100│ 10022│ 0│ 6510.04│ 40.35│ 0.98│ 15.36│200:10022
3s│ 100│ 14961│ 0│ 6448.37│ 40.35│ 0.98│ 15.51│200:14961
4s│ 100│ 19938│ 0│ 6451.98│ 40.35│ 0.98│ 15.50│200:19938
5s│ 100│ 24869│ 0│ 6443.08│ 40.35│ 0.98│ 15.52│200:24869
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address
请求失败: Get http://127.0.0.1:8088/: dial tcp 127.0.0.1:8088: connect: cannot assign requested address

请求失败: Post "http:": http: no Host in request URL

我在使用中貌似遇到了一些问题,载入curl时读取不到目标地址

我的笔记本

OS: Ubuntu 20.04 LTS x86_64
CPU: Intel i5-10210U (8) @ 4.200GHz

error message

$ ./go-stress-testing-linux -c 1 -n 1 -p test.curl.txt

 开始启动  并发数:1 请求数:1 请求参数: 
request:
 form:http 
 url:http:// 
 method:POST 
 headers:map[authorization:eyJOIjoxNTkyNzA5MzA3LCJFIjoxNTkzNDAwNTA3LCJEIjoiMTU4NTYzMDMxOTIifS5ya2s4MHUvUnIzZUFneHVQalJCWE4xckxLTkRwVnVhL0I4dkFLNSt1TFBRPQ==] 
 data: 
 verify:statusCode 
 timeout:30s 
 debu:false 

请求失败: Post "http:": http: no Host in request URL


─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────
 耗时│ 并发数│ 成功数│ 失败数│   qps  │最长耗时│最短耗时│平均耗时│ 错误码
─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────
   0s│      1│      0│      1│    0.00│    0.28│    0.28│    0.00│509:1


*************************  结果 stat  ****************************
处理协程数量: 1
请求总数: 1 总请求时间: 0.001 秒 successNum: 0 failureNum: 1
*************************  结果 end   ****************************

vi test.curl.txt

curl --request POST \
  --url http://10.20.121.176:23025/path... \
  --header 'authorization: joxNTkyNzA5MzA3LCJFIjoxNTkzNDAwNTA3LCJEIj...

test websocket

GetConn 建立连接失败 in... 0 websocket.Dial ws://localhost:8086/car/websocket?sceneId=5c861652e9cfa448f43290d1: bad status
GetConn 建立连接失败 in... 1 websocket.Dial ws://localhost:8086/car/websocket?sceneId=5c861652e9cfa448f43290d1: bad status
GetConn 建立连接失败 in... 2 websocket.Dial ws://localhost:8086/car/websocket?sceneId=5c861652e9cfa448f43290d1: bad status
GetConn 建立连接失败 3 websocket.Dial ws://localhost:8086/car/websocket?sceneId=5c861652e9cfa448f43290d1: bad status

what is problem?

websocket 压测成功数都是0,是正确的吗

go run main.go -c 10 -n 1 -u ws://127.0.0.1:4455/

开始启动 并发数:10 请求数:1 请求参数:
request:
url:ws://127.0.0.1:4455/
form:webSocket

method:GET
headers:map[]
verify:json
timeout:3s
debu:false

─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────
耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│ 错误码
─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────
1s│ 0│ 0│ 0│ 0.00│ 0.00│ 0.00│ 0.00│
2s│ 10│ 0│ 10│ 0.00│ 2.95│ 0.00│ 0.00│0:10
3s│ 10│ 0│ 10│ 0.00│ 2.95│ 0.00│ 0.00│0:10
4s│ 10│ 0│ 10│ 0.00│ 2.95│ 0.00│ 0.00│0:10

http 短连接

使用的是http短连接,我实际使用过程中出现了客户端大量time_wait问题。

windows 下链接断开会报错 An existing connection was forcibly closed by the remote host

我执行如下命令:.\go-stress-testing-win.exe -c 16 -n 1000 -u http://localhost/foo
其中会有一些错误提示影响查看统计数据:

请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64169->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64174->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64173->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
128s│ 16│ 15758│ 67│ 146.94│21119.76│ 2.99│ 6.81│200:15758;509:67
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64186->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64202->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64203->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
ly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64210->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64213->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64214->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64219->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64226->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64220->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64227->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64228->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.
请求失败: Get "http://localhost/foo": read tcp 127.0.0.1:64233->127.0.0.1:80: wsarecv: An existing connection was forcibly closed by the remote host.

当 PUT 方法带 body 时会被当作 POST 提交

我有个接口是使用 PUT 方法进行数据更新,我的 curl 文件大概是这样的:

curl -X PUT  http://domain.com/path \
    -H 'content-type: application/json' \
    -H 'Authorization: Bearer ...' \
    -H 'Accept: application/json' \
    -H 'X-Language: zh_cn' \
    -d '{"parts":1}'

但会被当作 POST 执行,看了下源码,在 curl_model.go 这个地方直接返回了 POST。

qps problem

如果单测http请求,最大能达到多大的qps呢?

依赖管理为什么不采用go mod呢~~

$ cat go.mod
module go-stress-testing

go 1.14

require golang.org/x/net v0.0.0-20190724013045-ca1201d0de80

感觉使用上比vendor方便点....
现在go mod的代理下载还是很快的..

json模板校验需求

在实际应用中对于接口请求返回的校验。不同项目可能方式不一样
A: {"code":200,"msg":"Success","data":{}}
B: {"httpCode":200,"status":"Success","info":{}}
...
诸如此类,我目前想到的方法是直接添加校验模板,通过参数代入。
有没有更好的方案,对Go这块不是很熟悉

文件上传

支持multipart/form-data 格式的表单提交吗?目前有个服务是通过multipartfile 来处理文件上传的。

并发超过7000就会报错 “net/http: request canceled (Client.Timeout exceeded while awaiting headers)”

使用压测时,使用命令“./go-stress-testing-linux -c 7500 -n 1 -u http://www.test1111.com”
此时会报错,
“请求失败: Get http://www.test1111.com: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
请求失败: Get http://www.test1111.com: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
请求失败: Get http://www.test1111.com: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
请求失败: Get http://www.test1111.com: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
请求失败: Get http://www.test1111.com: net/http: request canceled (Client.Timeout exceeded while awaiting headers)”

提示 cannot find package "go-stress-testing/model" in any of

➜ go-stress-testing git:(master) go run main.go -c 1 -n 100 -u https://www.baidu.com/
main.go:13:2: cannot find package "go-stress-testing/model" in any of:
/usr/local/go/src/go-stress-testing/model (from $GOROOT)
/Users/mac/go/src/go-stress-testing/model (from $GOPATH)
main.go:14:2: cannot find package "go-stress-testing/server" in any of:
/usr/local/go/src/go-stress-testing/server (from $GOROOT)
/Users/mac/go/src/go-stress-testing/server (from $GOPATH)
➜ go-stress-testing git:(master)

请教rpc压测如何使用

文档有写可以压测http、webSocket请求、私有rpc调用, 可是并未找到具体是如何压测rpc的 请指教 谢谢~

postman导出的curl请求无法用

postman导出的curl请求代码无法用,测试了后才发现是curl格式你好像只支持浏览器复制的curl格式,

建议兼容postman导出的curl格式,谢谢

平均耗时好像不对?

─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬────────
耗时│ 并发数│ 成功数│ 失败数│ qps │最长耗时│最短耗时│平均耗时│ 错误码
─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼────────
1s│ 10│ 162│ 0│ 166.76│ 83.38│ 53.16│ 6.00│200:162
2s│ 10│ 324│ 0│ 164.51│ 102.15│ 52.10│ 6.08│200:324
3s│ 10│ 489│ 0│ 165.25│ 102.15│ 52.10│ 6.05│200:489
4s│ 10│ 662│ 0│ 166.60│ 102.15│ 51.64│ 6.00│200:662
5s│ 10│ 822│ 0│ 165.70│ 107.08│ 51.64│ 6.04│200:822
6s│ 10│ 991│ 0│ 166.29│ 107.08│ 51.18│ 6.01│200:991
6s│ 10│ 1000│ 0│ 166.32│ 107.08│ 51.18│ 6.01│200:1000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.