Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for additional load balancing schemes #12

Open
p0pr0ck5 opened this issue Jun 29, 2016 · 1 comment
Open

Support for additional load balancing schemes #12

p0pr0ck5 opened this issue Jun 29, 2016 · 1 comment

Comments

@p0pr0ck5
Copy link
Contributor

Any plans to support additional load balancing schemes like hashing, least conn, etc? Regular old hashing wouldn't seem too hard (same with least_conn); consistent (ketama) hashing has already been done in https://github.com/agentzh/lua-resty-chash; perhaps we could wrap this? I'll happily contribute if you think this is worthwhile (I'd love to be able to wrap this lib using chashing for lua-resty-waf to connect to a cluster of persistent variable storage backends).

@hamishforbes
Copy link
Owner

Hey, yeah having other balancing methods was always in the plan.
At the moment I don't have a need for anything other than round-robin, so I don't have any concrete plans to add other methods myself.
More than happy to accept contribution for other methods though!

Should just be a case of adding a function to the available_methods table.
Maybe we need a register_balance_method function to add to that table dynamically or something...

p0pr0ck5 added a commit to p0pr0ck5/lua-resty-upstream that referenced this issue Jul 1, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants