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

More load balancing policies #5157

Merged
merged 1 commit into from
Mar 23, 2024
Merged

Conversation

machine424
Copy link
Contributor

@machine424 machine424 commented Mar 19, 2024

Fixes #5154

Add Random and Power of 2 choices policies.
Also, adjust the Round Robin policy to handle a special case.

@machine424 machine424 marked this pull request as draft March 19, 2024 15:29
@tsegismont
Copy link
Contributor

Please verify you have used the email associated to your Eclipse account and that you have signed-off your commit

@tsegismont tsegismont changed the title loadbalancing: add Random and Power of 2 choices policies More load balancing policies Mar 19, 2024
@tsegismont
Copy link
Contributor

I've changed the name of the PR because we'll use it to add all policies listed in #5154

@machine424
Copy link
Contributor Author

Please verify you have used the email associated to your Eclipse account and that you have signed-off your commit

I re-signed the ECA, maybe it needs some time to sync.

adjust the Round Robin policy to handle a special case.

Signed-off-by: machine424 <[email protected]>
@@ -29,4 +29,6 @@ public interface Endpoint<E> {
*/
EndpointMetrics<?> metrics();


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this.

public interface PreferenceAwareLoadBalancer {

/**
* TOO SIMPLE Hashing load balancer XXX. TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need this or should we just implement consistent hashing?
(that will require re-implementing some wheels as I don't see any exisiting lib/utils for that)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I need to put more thought into this. As I see it, the problem is the following:

  • we have for input either a value provided by the user or computed based on one or more request properties (e.g. client IP or, in the case of sticky sessions, the value of the session id).
  • given an input value, we need to be able to stick to the same endpoint (even if other endpoints join or leave)

I'm not sure how to do this right now

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class PreferenceAwareLoadBalancingCornerCasesTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should merge this with LoadBalancingCornerCasesTest?

* Select an endpoint among the provided list taking an attribute into account.
*
* @param endpoints the endpoint
* @param attribute the attribute TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do better for the naming/types?
also for the PreferenceAwarexxx

* @param attribute the attribute TODO
* @return the selected index or {@code -1} if selection could not be achieved
*/
int selectEndpoint(List<? extends Endpoint<?>> endpoints, String attribute);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or should we allow passing this attr/preference to all policies? it can be confusing.

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@machine424 thank you for this contribution

Would you agree to finish this PR with random and power of two choices algorithms only?

I think we all need to put more though into the problem of hashing/sticky session load balancing. I could create a separate issue and one of us would address in a follow-up PR.

public interface PreferenceAwareLoadBalancer {

/**
* TOO SIMPLE Hashing load balancer XXX. TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I need to put more thought into this. As I see it, the problem is the following:

  • we have for input either a value provided by the user or computed based on one or more request properties (e.g. client IP or, in the case of sticky sessions, the value of the session id).
  • given an input value, we need to be able to stick to the same endpoint (even if other endpoints join or leave)

I'm not sure how to do this right now

@machine424
Copy link
Contributor Author

Would you agree to finish this PR with random and power of two choices algorithms only?

I think we all need to put more though into the problem of hashing/sticky session load balancing. I could create a separate issue and one of us would address in a follow-up PR.

Fair enough, I agree with you.`
Removed the last commit, tell me if anything else needs to be added/adjusted.

@tsegismont tsegismont marked this pull request as ready for review March 23, 2024 09:55
Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @machine424 ! Thank you very much !

@tsegismont tsegismont merged commit eb08504 into eclipse-vertx:master Mar 23, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

More load balancing policies
3 participants