aboutsummaryrefslogtreecommitdiff
path: root/lbclient.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-11-09 19:11:48 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-11-09 19:11:48 +0200
commitb7e3627df21bf7f9ccd62080a047877e726cf2d3 (patch)
tree925ffae3a03afc744b08926b0f6eba7aa7ecc1ee /lbclient.go
parentLBClient: panic on empty Clients (diff)
downloadfasthttp-b7e3627df21bf7f9ccd62080a047877e726cf2d3.tar.gz
fasthttp-b7e3627df21bf7f9ccd62080a047877e726cf2d3.tar.bz2
fasthttp-b7e3627df21bf7f9ccd62080a047877e726cf2d3.zip
LBClient: prevent servers' hammering by randomizing the initial client to use
Diffstat (limited to 'lbclient.go')
-rw-r--r--lbclient.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/lbclient.go b/lbclient.go
index 17f1f57..41fe727 100644
--- a/lbclient.go
+++ b/lbclient.go
@@ -93,6 +93,10 @@ func (cc *LBClient) init() {
healthCheck: cc.HealthCheck,
})
}
+
+ // Randomize nextIdx in order to prevent initial servers'
+ // hammering from a cluster of identical LBClients.
+ cc.nextIdx = uint32(time.Now().UnixNano())
}
func (cc *LBClient) get() *lbClient {