proxyd/fix: error rate tolerance (#5606)
This commit is contained in:
parent
7a4a9b5c39
commit
bb4a592d77
@ -557,7 +557,11 @@ func (b *Backend) doForward(ctx context.Context, rpcReqs []*RPCReq, isBatch bool
|
||||
|
||||
// IsHealthy checks if the backend is able to serve traffic, based on dynamic parameters
|
||||
func (b *Backend) IsHealthy() bool {
|
||||
errorRate := b.networkErrorsSlidingWindow.Sum() / b.networkRequestsSlidingWindow.Sum()
|
||||
errorRate := float64(0)
|
||||
// avoid division-by-zero when the window is empty
|
||||
if b.networkRequestsSlidingWindow.Sum() >= 10 {
|
||||
errorRate = b.networkErrorsSlidingWindow.Sum() / b.networkRequestsSlidingWindow.Sum()
|
||||
}
|
||||
avgLatency := time.Duration(b.latencySlidingWindow.Avg())
|
||||
if errorRate >= b.maxErrorRateThreshold {
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user