diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-11-03 17:52:31 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-11-08 15:47:55 +0000 |
| commit | 8892efd4a3951d24d2b42529045868f36fd32617 (patch) | |
| tree | b3e84590b57849fd2fcc128ca30f6954625d7b7e /dashboard/app/cache.go | |
| parent | df3908d69f6b715681076b1555f6797bdd8e4bfd (diff) | |
dashboard: optimize throttling
At the peak times, concurrency at individual keys can be high.
Do the updates more carefully - if we denied the request and another
instance did the same concurrently, there's no point in retrying the
write. The object stored at the key already exceeds the limit.
Diffstat (limited to 'dashboard/app/cache.go')
| -rw-r--r-- | dashboard/app/cache.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dashboard/app/cache.go b/dashboard/app/cache.go index 14c8169c8..240a6a91f 100644 --- a/dashboard/app/cache.go +++ b/dashboard/app/cache.go @@ -312,8 +312,14 @@ func ThrottleRequest(c context.Context, requesterID string) (bool, error) { item.Object = obj err = memcache.Gob.CompareAndSwap(c, item) if err == memcache.ErrCASConflict { - // Update conflict. Retry. - continue + if ok { + // Only retry if we approved the query. + // If we denied and there was a concurrent write + // to the same object, it could have only denied + // the query as well. + // Our save won't change anything. + continue + } } else if err != nil { return false, err } |
