From 0162529ea53e4ed2195a34ede29f7ef623af87dd Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Thu, 28 May 2015 15:50:39 -0700 Subject: [PATCH] Default minRequestTimeout to 1800s --- cmd/kube-apiserver/app/server.go | 2 +- pkg/apiserver/watch.go | 4 ++-- pkg/master/master.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index b3eca45d191..eba9e7fa6e6 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -205,7 +205,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/") fs.StringVar(&s.ExternalHost, "external-hostname", "", "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs.)") fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", 400, "The maximum number of requests in flight at a given time. When the server exceeds this, it rejects requests. Zero for no limit.") - fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", 300, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out.") + fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", 1800, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out. Currently only honored by the watch request handler, which picks a randomized value above this number as the connection timeout, to spread out load.") fs.StringVar(&s.LongRunningRequestRE, "long-running-request-regexp", "[.*\\/watch$][^\\/proxy.*]", "A regular expression matching long running requests which should be excluded from maximum inflight request handling.") } diff --git a/pkg/apiserver/watch.go b/pkg/apiserver/watch.go index 5a10239a3df..1be779e3611 100644 --- a/pkg/apiserver/watch.go +++ b/pkg/apiserver/watch.go @@ -69,8 +69,8 @@ func (w *realTimeoutFactory) TimeoutCh() (<-chan time.Time, func() bool) { func serveWatch(watcher watch.Interface, scope RequestScope, w http.ResponseWriter, req *restful.Request, minRequestTimeout int) { var timeout time.Duration if minRequestTimeout > 0 { - // Each watch gets a random timeout to avoid thundering herds. Rand is seeded once in the api installer. - timeout = time.Duration(minRequestTimeout+rand.Intn(2*minRequestTimeout-minRequestTimeout)) * time.Second + // Each watch gets a random timeout between minRequestTimeout and 2*minRequestTimeout to avoid thundering herds. + timeout = time.Duration(minRequestTimeout+rand.Intn(minRequestTimeout)) * time.Second } watchServer := &WatchServer{watcher, scope.Codec, func(obj runtime.Object) { if err := setSelfLink(obj, req, scope.Namer); err != nil { diff --git a/pkg/master/master.go b/pkg/master/master.go index ad76e0f3bc8..9b2d4fa60d7 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -112,7 +112,7 @@ type Config struct { RestfulContainer *restful.Container // If specified, requests will be allocated a random timeout between this value, and twice this value. - // Note that it is upto the request handlers to ignore or honor this timeout. + // Note that it is up to the request handlers to ignore or honor this timeout. MinRequestTimeout int // Number of masters running; all masters must be started with the