mirror of https://github.com/status-im/consul.git
consul: lower default query time and add small stagger
This commit is contained in:
parent
c51c888142
commit
ab3632e409
|
@ -30,6 +30,15 @@ const (
|
|||
// maxQueryTime is used to bound the limit of a blocking query
|
||||
maxQueryTime = 600 * time.Second
|
||||
|
||||
// defaultQueryTime is the amount of time we block waiting for a change
|
||||
// if no time is specified. Previously we would wait the maxQueryTime.
|
||||
defaultQueryTime = 300 * time.Second
|
||||
|
||||
// jitterFraction is a the limit to the amount of jitter we apply
|
||||
// to a user specified MaxQueryTime. We divide the specified time by
|
||||
// the fraction. So 16 == 6.25% limit of jitter
|
||||
jitterFraction = 16
|
||||
|
||||
// Warn if the Raft command is larger than this.
|
||||
// If it's over 1MB something is probably being abusive.
|
||||
raftWarnSize = 1024 * 1024
|
||||
|
@ -332,9 +341,12 @@ func (s *Server) blockingRPCOpt(opts *blockingRPCOptions) error {
|
|||
if opts.queryOpts.MaxQueryTime > maxQueryTime {
|
||||
opts.queryOpts.MaxQueryTime = maxQueryTime
|
||||
} else if opts.queryOpts.MaxQueryTime <= 0 {
|
||||
opts.queryOpts.MaxQueryTime = maxQueryTime
|
||||
opts.queryOpts.MaxQueryTime = defaultQueryTime
|
||||
}
|
||||
|
||||
// Apply a small amount of jitter to the request
|
||||
opts.queryOpts.MaxQueryTime += randomStagger(opts.queryOpts.MaxQueryTime / jitterFraction)
|
||||
|
||||
// Setup a query timeout
|
||||
timeout = time.NewTimer(opts.queryOpts.MaxQueryTime)
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ query string parameter to the value of `X-Consul-Index`, indicating that the cli
|
|||
to wait for any changes subsequent to that index.
|
||||
|
||||
In addition to `index`, endpoints that support blocking will also honor a `wait`
|
||||
parameter specifying a maximum duration for the blocking request. If not set, it will
|
||||
default to 10 minutes. This value can be specified in the form of "10s" or "5m" (i.e.,
|
||||
10 seconds or 5 minutes, respectively).
|
||||
parameter specifying a maximum duration for the blocking request. This is limited to
|
||||
10 minutes. If not set, the wait time defaults to 5 minutes. This value can be specified
|
||||
in the form of "10s" or "5m" (i.e., 10 seconds or 5 minutes, respectively).
|
||||
|
||||
A critical note is that the return of a blocking request is **no guarantee** of a change. It
|
||||
is possible that the timeout was reached or that there was an idempotent write that does
|
||||
|
|
Loading…
Reference in New Issue