From 26ca78936c2916373af536b514689f13abf89325 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sun, 10 Jul 2016 13:23:43 -0400 Subject: [PATCH] consul: Add RPCHoldTimeout as tunable hold period --- consul/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/consul/config.go b/consul/config.go index 78b3fc8753..8e252b6351 100644 --- a/consul/config.go +++ b/consul/config.go @@ -224,6 +224,13 @@ type Config struct { // are willing to apply in one period. After this limit we will issue a // warning and discard the remaining updates. CoordinateUpdateMaxBatches int + + // RPCHoldTimeout is how long an RPC can be "held" before it is errored. + // This is used to paper over a loss of leadership by instead holding RPCs, + // so that the caller experiences a slow response rather than an error. + // This period is meant to be long enough for a leader election to take + // place, and a small jitter is applied to avoid a thundering herd. + RPCHoldTimeout time.Duration } // CheckVersion is used to check if the ProtocolVersion is valid @@ -286,6 +293,9 @@ func DefaultConfig() *Config { CoordinateUpdatePeriod: 5 * time.Second, CoordinateUpdateBatchSize: 128, CoordinateUpdateMaxBatches: 5, + + // Hold an RPC for up to 5 seconds by default + RPCHoldTimeout: 5 * time.Second, } // Increase our reap interval to 3 days instead of 24h.