Documentation ¶
Overview ¶
P2C will distribute the traffic by choosing two hosts either via hashing or randomly and then pick the least loaded of the two. It gaurantees that the max load of a server is ln(ln(n)), where n is the number of servers.
All operations in P2C are concurrency-safe.
For more info: https://brooker.co.za/blog/2012/01/17/two-random.html
http://www.eecs.harvard.edu/~michaelm/postscripts/handbook2001.pdf
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type P2C ¶
func (*P2C) Balance ¶
Balance picks two servers either randomly (if no key supplied), or via hashing (PKG) if given a key, then it returns the least loaded one between the two.
Partial Key Grouping (PKG) is great for skewed data workloads, which also needs to be determinstic in the way of choosing which servers to send requests too. https://arxiv.org/pdf/1510.07623.pdf the maximum load of a server in PKG at anytime is: `max_load-avg_load`