Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

高并发下遇到的问题 #365

Open
zedfaker opened this issue Apr 6, 2023 · 9 comments
Open

高并发下遇到的问题 #365

zedfaker opened this issue Apr 6, 2023 · 9 comments

Comments

@zedfaker
Copy link

zedfaker commented Apr 6, 2023

进行压力测试时发生的问题

在我使用jmeter进行压力测试的时候,一开始还好好的,但是到了后面就发生了异常,报错内容为EOF。

示例代码如下:

err = gout.POST(config.Url).
			SetProxy(config.Proxy).
			SetTimeout(30 * time.Second).
			Debug(true).
			SetHeader(head).
			Code(&request.ResultCode).
			SetBody(&request.ResultBody).
			Do()

在网上寻求帮助时,可能是因为服务器关闭连接的时候又接收到新的请求,导致此次请求被服务器拒绝而失败。当时他给出的解决方案是设置request的close属性为true,例:req.close = true。

所以,我想请问下,使用gout包的时候,如何解决这个问题。

@guonaihong
Copy link
Owner

对于“在我使用jmeter进行压力测试的时候,一开始还好好的,但是到了后面就发生了异常,报错内容为EOF。”

我理解下,你的服务端是goalng 写的http服务,使用jmeter进行压力测试,里面有段代码是用gout进行了转发?压力太多,出现EOF的问题?

@zedfaker
Copy link
Author

zedfaker commented Apr 6, 2023

是的,场景是这个场景,我仔细描述下就是,使用gin框架搭建的http服务,其中是需要调用其他的web服务端,所以中间是使用了gout进行了http的请求。后来用jmeter进行压力测试的时候,并发数量在70的时候,大概在几万次请求的时候就会出现eof的问题

@guonaihong
Copy link
Owner

gout请求的服务端也是golang写的吗?还是nginx的?

@zedfaker
Copy link
Author

zedfaker commented Apr 6, 2023

gout请求的服务端在测试中是使用的java的springboot的web项目,但是在未来的需求中是不确定的

@guonaihong
Copy link
Owner

eof一般是对端关闭连接。往这个思路走,你可以先控制下变量,比如jmeter直接压springboot有没有这个现象。
如果有: 就看下springboot。
没有的话:我这边再分析下。

上面提的req.close = true 不建议使用,会让http 1.1的协议会退化成http 1.0一个tcp一个http连接(http 2.0没试过)。对服务端或者客户端来说会占用更多的tcp资源。

@zedfaker
Copy link
Author

zedfaker commented Apr 6, 2023

image
目前测试直接压是没有这个问题的,报错的百分之0.01是因为我停止压测而导致的socketClose异常,并不是之前提到的eof问题。

@guonaihong
Copy link
Owner

guonaihong commented Apr 6, 2023

你修改下gout代码,先开大http client的连接池个数。试下可有改善。

gout.New(&dataflow.DefaultBenchClient).POST(config.Url).
			SetProxy(config.Proxy).
			SetTimeout(30 * time.Second).
			Debug(true).
			SetHeader(head).
			Code(&request.ResultCode).
			SetBody(&request.ResultBody).
			Do()

@guonaihong
Copy link
Owner

@zedfaker 好了吗?

@zedfaker
Copy link
Author

zedfaker commented Apr 7, 2023

不好意思,测试环境有别的问题,暂时还没有解决环境问题,我这边如果有结论了会第一时间和你联系的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants