At many places, HTTP requests have been implemented using default HTTP client like r, err := http.Get(s.metadata.url). As per HTTP package, default client is defined like this var DefaultClient = &Client{}. This has huge drawbacks as it doesn't allow the application to define timeout behaviors (among other things). The default value of timeout is 0 which means no timeout. In production environments, this could prove costly. The more intuitive way would be to create your own client like
client := &http.Client{
Timeout: x * time.Second, // x seconds timeout
}
and http.NewRequest() to create new requests.
@aman-bansal do you think we should allow users to specify such parameters on a case by case basis or should we introduce good-enough default?
There are two ways to look at this:
What I think is we should define one parameter in metadata for each scaler (where timeouts make sense) with good enough default value.
I agree with both of those points @aman-bansal, but I would add that we should allow users to set a global timeout should they desire.
I would like to work on this. I'll send a draft PR as a start.
Created https://github.com/kedacore/charts/issues/109 to surface this in our Helm chart as well.
Most helpful comment
I agree with both of those points @aman-bansal, but I would add that we should allow users to set a global timeout should they desire.
I would like to work on this. I'll send a draft PR as a start.