KeisukeYamashita / consistent

Consistent hashing with bounded loads in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consistent

Go written consistent hashing package inspired by Google's "Consistent Hashing with Bounded Loads"

CI Release

Dependabot Badge GoDoc Badge Snyk Badge FOSSA Status

If you don't know the consistent hashing, please refer to Introducing Consistent Hashing, Teiva Harsanyi to learn about it!

References

Install

Please run to install the package:

$ go get -u github.com/KeisukeYamashita/consistent

Configuration

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
}

Usage

Contributions

All contributions are welcome, please file a issue or a pull request 🚀

License

Apache License 2.0.

Acknowledgements

This package was inspired heavily by these packages:

Thank you very much for open sourcing these hard work.

About

Consistent hashing with bounded loads in Golang

License:Apache License 2.0


Languages

Language:Go 100.0%