consistent

package
v0.0.0-...-2321f9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2017 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consistent

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

func New

func New(hosts ...string) *Consistent

func (*Consistent) Add

func (c *Consistent) Add(host string)

func (*Consistent) Balance

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

func (*Consistent) Remove

func (c *Consistent) Remove(host string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL