liblb: github.com/lafikl/liblb/consistent Index | Files

package consistent

import "github.com/lafikl/liblb/consistent"

Consistent uses consistent hashing algorithm to assign work to hosts. Its best for the cases when you need affinty, and your hosts come and go. When removing a host it gaurantees that only 1/n of items gets reshuffled where n is the number of servers.

One of the issues with Consistent Hashing is load imbalance when you have hot keys that goes to a single server, it's mitigated by using virtual nodes, which basically means when adding a host we add n - 20 in our case - replicas of that host.

Beware that Consistent Hashing doesn't provide, an upper bound for the load of a host.

If you need such gaurantees see package liblb/bounded.

https://en.wikipedia.org/wiki/Consistent_hashing

Index

Package Files

consistent.go

type Consistent Uses

type Consistent struct {
    // contains filtered or unexported fields
}

func New Uses

func New(hosts ...string) *Consistent

func (*Consistent) Add Uses

func (c *Consistent) Add(host string)

func (*Consistent) Balance Uses

func (h *Consistent) Balance(key string) (host string, err error)

func (*Consistent) Remove Uses

func (c *Consistent) Remove(host string)

Package consistent imports 2 packages (graph). Updated 2020-03-24. Refresh now. Tools for package owners.