forked from hamishforbes/lua-resty-upstream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement hash load balancing method
Add a new hash load balancing method to resty.upstream.socket. This hash is a CRC32 of the given key modulo the sum of weights of available hosts. 'Available hosts' are determined before a connection attempt is made, so that host weights can be taken into account when deriving the hash. This stands in contrast to the existing round robin implementation, which walks the entire list of host and then checks its availability after making a weighted decision. Hash keys can be provided by an optional param to upstream:connect(). It would make more sense to provide a function to derive the key as part of defining the pool, but because pools are serialized as JSON, this is a no-go. See issue hamishforbes#12 for the initial discussion regarding additional load balancing schemes.
- Loading branch information
Showing
3 changed files
with
583 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.