Closed jiuker closed 11 months ago
This is fixing #16 - right?
@harshavardhana While I do believe this is a better default than round-robin, I think RR should still be an option, or did you already discuss this?
This is fixing #16 - right?
@harshavardhana While I do believe this is a better default than round-robin, I think RR should still be an option, or did you already discuss this?
yeah. Fixing #16
@harshavardhana While I do believe this is a better default than round-robin, I think RR should still be an option, or did you already discuss this?
It can be an option, we can take a flag that says --host-balance=leastconn
or --host-balance=random
Currently what we support is random not round-robin
Code LGTM, but some minor things:
A) change "leastconn" to just least
B) Default should be least
- it is by far better overall. Deals better with requests of varying latency and varying host speed.
C) We should never select hosts that are marked offline, since this will return many more errors if a host is down.
it is by far better overall
1 and 2 are there.
func (s *site) upBackends() []*Backend {
var backends []*Backend
for _, backend := range s.backends {
if backend.Online() {
backends = append(backends, backend)
}
}
return backends
}
func (s site) nextProxy() (Backend, func()) { backends := s.upBackends() if len(backends) == 0 { return nil, func() {} }
@klauspost
@harshavardhana cc
support least connections