From 236112c6af9b22b02e35914fe8fbbdbfe856f975 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 8 Oct 2019 14:27:28 -0700 Subject: [PATCH] increase auth cache size --- .../token/cache/cached_token_authenticator.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go index ea3853a38b4..2ffda6f1bb4 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/cached_token_authenticator.go @@ -62,7 +62,14 @@ func newWithClock(authenticator authenticator.Token, cacheErrs bool, successTTL, cacheErrs: cacheErrs, successTTL: successTTL, failureTTL: failureTTL, - cache: newStripedCache(32, fnvHashFunc, func() cache { return newSimpleCache(128, clock) }), + // Cache performance degrades noticeably when the number of + // tokens in operation exceeds the size of the cache. It is + // cheap to make the cache big in the second dimension below, + // the memory is only consumed when that many tokens are being + // used. Currently we advertise support 5k nodes and 10k + // namespaces; a 32k entry cache is therefore a 2x safety + // margin. + cache: newStripedCache(32, fnvHashFunc, func() cache { return newSimpleCache(1024, clock) }), } }