diff --git a/iopool/pool.go b/iopool/pool.go index ae8672f..c1d28b8 100644 --- a/iopool/pool.go +++ b/iopool/pool.go @@ -6,6 +6,7 @@ package iopool import ( "bufio" "errors" + "hash/fnv" "net" "strings" "sync/atomic" @@ -89,13 +90,9 @@ func (c *Collection) pick(key string) int { // compute the server to choose for key // deterministic given set of servers and key - x := byte(37) - for _, c := range key { - x ^= byte(c) - } - idx := int(int(x) % len(c.pools)) - - return idx + h := fnv.New64a() + _, _ = h.Write([]byte(key)) + return int(h.Sum64() % uint64(len(c.pools))) } func (c *Collection) Get(key string) (*Buffer, error) {