diff --git a/internal/prober/prober.go b/internal/prober/prober.go index f6dc6f1..3dddb48 100644 --- a/internal/prober/prober.go +++ b/internal/prober/prober.go @@ -177,9 +177,11 @@ func (p *Prober) SortedByLatency() []*UpstreamHealth { if aDown != bDown { return bDown // non-down first } - // Within 10% latency difference: prefer lower priority number. + // Within 10% latency difference: prefer lower priority number, then lower latency. if b.EMALatency > 0 && math.Abs(a.EMALatency-b.EMALatency)/b.EMALatency < 0.10 { - return a.Priority < b.Priority + if a.Priority != b.Priority { + return a.Priority < b.Priority + } } return a.EMALatency < b.EMALatency })