Enable configuring Net::HTTP
timeouts
#222
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋 !
We recently had an issue in our infrastructure where a Push Gateway was getting overloaded due to too much metric cardinality in the time series data that we were sending. We remedied this issue and things are well, but part of the way we noticed was that these pushes were happening in our job workers, which we have a lot of timing instrumentation around.
Digging in a bit further, we noticed that a huge number jobs were taking 60 seconds to complete, when they are normally much (sub-second) faster. We realized that this was due to our calls out to the push gateway, which would eventually time out. We wanted to be able to set the push timeout to be significantly lower (1-5 seconds) so that we can fail fast and avoid eating into our job capacity if there is ever an issue with our gateways again.
Looking at the Ruby documentation for Net::HTTP, both
read_timeout
andopen_timeout
have a default timeout of 60 seconds:This PR allows a user to pass through the
read_timeout
andopen_timeout
in the initialization of a newPush
class, but retains the defaults otherwise. I am not in love with using**kwargs
, and am open to other methods of configuring this value (and happy to implement them myself). I do believe that it's important to give the user control of these values however.Thanks!