Skip to content

Commit

Permalink
Change rate limiter burst size to 1 (cadence-workflow#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyassrivatsan authored Jul 22, 2019
1 parent e73fc9f commit 8766b37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/quotas/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (d *MultiStageRateLimiter) Allow(info Info) bool {
if !ok {
// create a new limiter
initialRps := d.domainRPS()
domainLimiter := NewRateLimiter(&initialRps, _defaultRPSTTL, _burstMultiplier*int(d.domainRPS()))
domainLimiter := NewRateLimiter(&initialRps, _defaultRPSTTL, _burstSize)

// verify that it is needed and add to map
d.Lock()
Expand Down
8 changes: 4 additions & 4 deletions common/quotas/ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
)

const (
_defaultRPSTTL = 60 * time.Second
_burstMultiplier = 2
_defaultRPSTTL = 60 * time.Second
_burstSize = 1
)

// RateLimiter is a wrapper around the golang rate limiter handling dynamic
Expand All @@ -55,7 +55,7 @@ type RateLimiter struct {
// limiter
func NewSimpleRateLimiter(rps int) *RateLimiter {
initialRps := float64(rps)
return NewRateLimiter(&initialRps, _defaultRPSTTL, _burstMultiplier*rps)
return NewRateLimiter(&initialRps, _defaultRPSTTL, _burstSize)
}

// NewRateLimiter returns a new rate limiter that can handle dynamic
Expand Down Expand Up @@ -144,7 +144,7 @@ type DynamicRateLimiter struct {
// NewDynamicRateLimiter returns a rate limiter which handles dynamic config
func NewDynamicRateLimiter(rps RPSFunc) *DynamicRateLimiter {
initialRps := rps()
rl := NewRateLimiter(&initialRps, _defaultRPSTTL, _burstMultiplier*int(rps()))
rl := NewRateLimiter(&initialRps, _defaultRPSTTL, _burstSize)
return &DynamicRateLimiter{rps, rl}
}

Expand Down

0 comments on commit 8766b37

Please sign in to comment.