-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
nsqd: configurable HTTP client transport timeout #776
nsqd: configurable HTTP client transport timeout #776
Conversation
@kenjones-cisco thanks for this! I have a high level comment first. If we're going to land this, we should probably just do #680 as well, because the timeout as implemented is really a read/write deadline on the connection and has unexpected behavior. If we do #680, we should introduce two configurable values, What do you think? |
@mreiferson That makes sense. Let me take a look. |
Also, let's not forget to update |
de57ee8
to
d6c0ce9
Compare
@mreiferson changes made, just saw the comment about the example config file. Based on #715 I thought it was command line options. For nsqd and nsqadmin, the options should be specified for the configuration file as well? |
Might only be |
@@ -19,7 +19,6 @@ type deadlinedConn struct { | |||
} | |||
|
|||
func (c *deadlinedConn) Read(b []byte) (n int, err error) { | |||
c.Conn.SetReadDeadline(time.Now().Add(c.Timeout)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should drop the one in Write
too
506cd97
to
c422904
Compare
@mreiferson Looks like the DiskQueue test failure is back; otherwise all changes based on feedback are completed. |
@@ -27,6 +27,8 @@ var ( | |||
channel = flag.String("channel", "", "NSQ channel") | |||
statusEvery = flag.Duration("status-every", -1, "(deprecated) duration of time between polling/printing output") | |||
interval = flag.Duration("interval", 2*time.Second, "duration of time between polling/printing output") | |||
httpConnectTimeout = flag.Duration("http-client-connect-timeout", 2*time.Second, "timeout for HTTP connect") | |||
httpRequestTimeout = flag.Duration("http-client-request-timeout", 2*time.Second, "timeout for HTTP request") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think of this before, but now that we're setting a real request timeout, which encapsulates connection time, we should set the default request timeout to something greater than connect, say 5s
?
cc @jehiah
@mreiferson Just let me know when a default is decided. |
@kenjones-cisco let's go with |
c422904
to
7e8913f
Compare
@mreiferson all done (also ran fmt.sh to make sure everything is properly formatted) |
httpTimeout = flag.Duration("http-timeout", 20*time.Second, "timeout for HTTP connect/read/write (each)") | ||
statusEvery = flag.Int("status-every", 250, "the # of requests between logging status (per handler), 0 disables") | ||
contentType = flag.String("content-type", "application/octet-stream", "the Content-Type used for POST requests") | ||
// deprecate? in favor of http-client-connect-timeout, http-client-request-timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, can you put the // TODO:
prefix on this so it shows up in searches?
7e8913f
to
2e07a9f
Compare
@mreiferson Let me know if there is any more feedback. |
@@ -45,6 +45,9 @@ var ( | |||
rotateSize = flag.Int64("rotate-size", 0, "rotate the file when it grows bigger than `rotate-size` bytes") | |||
rotateInterval = flag.Duration("rotate-interval", 0*time.Second, "rotate the file every duration") | |||
|
|||
httpConnectTimeout = flag.Duration("http-client-connect-timeout", 5*time.Second, "timeout for HTTP connect") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be 2s
@kenjones-cisco found a few more inconsistencies, thanks for your patience! |
Some were previously hard-coded to a specific value so I left those to avoid breaking existing functionality. But I can make the changes. |
@kenjones-cisco appreciate that, and I think we can still accomplish that by preserving those previously hard-coded values as the defaults for the flags, for those applications. What will be new (and potentially unexpected) is that we are now introducing a separate connection timeout in those cases. I believe |
2e07a9f
to
454cf2f
Compare
@mreiferson all changes completed |
LGTM, thanks! |
Adds configuration options HTTPClientConnectTimeout and
HTTPClientRequestTimeout to control the connection and request timeout
repectively of the HTTP client.
Also added to the following app binaries:
Closes #715
Closes #680