Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Make the ConsulCache wait time less than OkHttp read timeout #255

Closed
alugowski opened this issue Jul 29, 2017 · 2 comments
Closed

Make the ConsulCache wait time less than OkHttp read timeout #255

alugowski opened this issue Jul 29, 2017 · 2 comments

Comments

@alugowski
Copy link
Contributor

I think the defaults could be adjusted to have fewer people experience the constant timeout as seen by #135 .

There are two timers in a cache. One is the read timeout, which is how long OkHttp will wait for a response (OkHttp default is 10s). The second is the blocking request wait time, and consul-client default is also 10s.

But see this in the Consul blocking queries docs (https://www.consul.io/api/index.html#blocking-queries):

A small random amount of additional wait time is added to the supplied maximum wait time to spread out the wake up time of any concurrent requests. This adds up to wait / 16 additional time to the maximum duration.

What's happening is that that jitter makes Consul reply in slightly longer than 10s, which makes OkHttp time out with the ugly exception seen in #135.

I suggest making the default watchSeconds value 8s, so that this extra jitter (plus a little margin) makes it much less likely for default OkHttp configs to cause time outs.

@yfouquet
Copy link
Collaborator

Hi @alugowski ,
I think that #289 fixed your issue, and it can be closed.
Instead of setting the default watch to 8 seconds, it increased the timeout depending on the wait duration.

@alugowski
Copy link
Contributor Author

That looks like it should work, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants