-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
The default IdleTimeout for long connections of the go-zero http service is set to 2.4s #4545
Comments
I think the current code is not a bug; rather, it's a designed behavior to fine-tune the
What Would Happen if You Removed the Factors?
|
I agree that it is necessary to set ReadTimeout and WriteTimeout, but after setting ReadTimeout, go-zero does not set IdleTimeout. At this time, IdleTimeout will use the value of ReadTimeout, causing the go-zero service to actively disconnect after the http long connection is idle for 2.4s. I think this is unreasonable. |
In addition, the 502 error occurs when go-zero actively closes the persistent connection, and the upstream reuses the closed persistent connection. Because the upstream may not have received the tcp fin network packet at this time, this has nothing to do with ReadTimeout and WriteTimeout. This is a low-probability problem that may only occur in high-concurrency scenarios. In my case, the probability of 502 is 0.001% under 1000qps concurrency. |
The default IdleTimeout for long connections of the http service is set to 2.4s
When using go-zero to start an http service, go-zero will set the default ReadTimeout to 0.8*3s (the default timeout of the route)
The code is
In the go http.Server api, if IdleTimeout is not set and ReadTimeout is set, IdleTimeout will use the value of ReadTimeout, which means that when the connection is idle for 2.4 seconds, the service will actively disconnect the long connection.
In my scenario, the gateway uses a long connection pool when connecting to the go-zero service. The connection idle time of the long connection pool is 60s. When performing stress testing, there is a 0.001% probability of a 502 gateway error.
To Reproduce
Expected behavior
The default IdelTimeout should be set more reasonably, not using the value of ReadTimeout by default, and providing configuration for user definition
Screenshots
No screenshots
Environments (please complete the following information):
More description
I can solve this problem by using rest.StartWithOpts and a custom IdleTimeout at startup, but I think this is a bug.
The text was updated successfully, but these errors were encountered: