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 different EndpointRoutingMode #1842

Merged
merged 2 commits into from
Oct 16, 2023
Merged

Support different EndpointRoutingMode #1842

merged 2 commits into from
Oct 16, 2023

Conversation

bjqian
Copy link
Contributor

@bjqian bjqian commented Oct 12, 2023

Summary of the changes

  • Add different endpoint routing mode: Weighted, LeastConnection, Random
  • For weighted mode: change the weight definition from remaining connection quota to ( remaining connection quota / connection capacity)

@@ -69,7 +80,7 @@ private ServiceEndpoint GetEndpointAccordingToWeight(ServiceEndpoint[] available
var remain = endpointMetrics.ConnectionCapacity -
(endpointMetrics.ClientConnectionCount +
endpointMetrics.ServerConnectionCount);
var weight = remain > 0 ? remain : 1;
var weight = Math.Max((int)((double)remain / endpointMetrics.ConnectionCapacity * 1000), 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: we can keep it in integer operations:
remain * 1000 / endpointMetrics.ConnectionCapacity
unit 1000 * 1000 connections/unit * 1000 = 1G, it is less than max value of integer (2G).

@bjqian bjqian merged commit f595647 into dev Oct 16, 2023
5 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.

2 participants