Go written consistent hashing package inspired by Google's "Consistent Hashing with Bounded Loads"
If you don't know the consistent hashing, please refer to Introducing Consistent Hashing, Teiva Harsanyi to learn about it!
- Consistent Hashing with Bounded Loads on Google Research Blog
- Improving load balancing with a new consistent-hashing algorithm on Vimeo Engineering Blog
- Consistent Hashing with Bounded Loads paper on arXiv
Please run to install the package:
$ go get -u github.com/KeisukeYamashita/consistent
type Config struct {
// Hasher is responsible for generating unsigned, 64 bit hash of provided byte slice.
Hasher Hasher
// Partition represents the number of partitions created on a ring.
// Partitions are used to divide the ring and assign bin and ball.
// Balls are distributed among partitions. Prime numbers are good to
// distribute keys uniformly. Select a big number if you have too many keys.
Partition int
// Bins are replicated on consistent hash ring.
// It's known as virtual nodes to uniform the distribution.
ReplicationFactor int
// LoadBalancingParameter is used to calculate average load.
// According to the Google paper, one or more bins will be adjusted so that they do not exceed a specific load.
// The maximum number of partitions are calculated by LoadBalancingParameter * (number of balls/number of bins).
LoadBalancingParameter float64
}
All contributions are welcome, please file a issue or a pull request 🚀
This package was inspired heavily by these packages:
Thank you very much for open sourcing these hard work.