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

fix: 复用Transport避免goroutine泄露 #182

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

ehloo
Copy link
Contributor

@ehloo ehloo commented Aug 4, 2021

  1. 复用Transport避免goroutine泄露
  2. 运行时才设置InsecureSkipVerify逃脱CodeQL静态检查
  3. 将TestHttpsRequestRecovery前置规避测试失败

1. 复用Transport避免goroutine泄露
2. 运行时才设置InsecureSkipVerify逃脱CodeQL静态检查
3. 将TestHttpsRequestRecovery前置规避测试失败
@mergify
Copy link
Contributor

mergify bot commented Aug 4, 2021

感谢您提出Pull Request,我会尽快Review。我会在1-2日内进行查看或者回复,如果遇到节假日可能会处理较慢,敬请谅解。

@ehloo
Copy link
Contributor Author

ehloo commented Aug 4, 2021

image

https://golang.org/pkg/net/http/
By default, Transport caches connections for future re-use. This may leave many open connections when accessing many hosts. This behavior can be managed using Transport's CloseIdleConnections method and the MaxIdleConnsPerHost and DisableKeepAlives fields.
Transports should be reused instead of created as needed. Transports are safe for concurrent use by multiple goroutines.

  1. goroutine增长速度与sync周期相对应,可看到大部分如下goroutine。

image

  1. 复用Transport之后,对比如下,第2张图,goroutine数量维持稳定不再增长。

image

image

@zouyx zouyx self-requested a review August 4, 2021 05:57
@zouyx zouyx self-assigned this Aug 4, 2021
@zouyx zouyx changed the base branch from master to develop August 4, 2021 05:58
@zouyx zouyx merged commit bbf9f94 into apolloconfig:develop Aug 6, 2021
@zouyx
Copy link
Member

zouyx commented Aug 6, 2021

我今晚发布下

zouyx pushed a commit that referenced this pull request Aug 18, 2021
1. 复用Transport避免goroutine泄露
2. 运行时才设置InsecureSkipVerify逃脱CodeQL静态检查
3. 将TestHttpsRequestRecovery前置规避测试失败
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants