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

Add client proxy load balancing support #56

Merged
merged 3 commits into from
Jun 5, 2020

Conversation

iffyio
Copy link
Collaborator

@iffyio iffyio commented Jun 3, 2020

This commit adds RoundRobin and Random load balancing
support to a proxy as well as config support for multiple
addresses and load balancer policy on the client proxy config.
The default behavior if no policy is set or is a server proxy
sends packets to all endpoints.

This also introduces the rand crate as a dependency, used by
the random load balancing implementation.

Resolves #3

@iffyio iffyio requested a review from markmandel June 3, 2020 19:55
@markmandel markmandel added area/user-experience Pertaining to developers trying to use Quilkin, e.g. cli interface, configuration, etc kind/feature New feature or request labels Jun 3, 2020
This commit adds RoundRobin and Random load balancing
support to a proxy as well as config support for multiple
addresses and load balancer policy on the client proxy config.
The default behavior if no policy is set or is a server proxy
sends packets to all endpoints.

This also introduces the `rand` crate as a dependency, used by
the random load balancing implementation.

Resolves #3
@iffyio iffyio force-pushed the iu/load-balancer-policy branch from 485cce8 to 17b3998 Compare June 3, 2020 19:56
Copy link
Contributor

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

This looks awesome. The only nit I could find was to make a change the client proxy example in /examples. 🙌

pub enum LoadBalancerPolicy {
/// Send all traffic to all endpoints.
#[serde(rename = "BROADCAST")]
Broadcast,
Copy link
Contributor

Choose a reason for hiding this comment

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

BROADCAST! Nice!

@@ -69,8 +64,9 @@ pub enum ConnectionConfig {
/// Client is the configuration for a client proxy, for sitting behind a game client.
#[serde(rename = "client")]
Client {
address: SocketAddr,
addresses: Vec<SocketAddr>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to also update https://github.com/googleforgames/quilkin/blob/master/examples/client-proxy.yaml, since that is the closest thing we have to docs right now.

(We should really write some docs 😃 )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the examples config!

/// EndpointChooser chooses from a set of endpoints that a proxy is connected to.
trait EndpointChooser: Send + Sync {
/// choose_endpoints asks for the next endpoint(s) to use.
fn choose_endpoints(&self) -> Vec<EndPoint>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is super elegant 🔥

.choose_endpoints()
.iter()
.map(|e| e.address)
.collect::<Vec<_>>())
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL about Vec<_>!

}
}

/// RandomEndpointChooser chooses endpoints in round-robin order.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// RandomEndpointChooser chooses endpoints in round-robin order.
/// RandomEndpointChooser chooses endpoints in a random order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Awesome.

@markmandel markmandel merged commit f2d329a into master Jun 5, 2020
@markmandel markmandel deleted the iu/load-balancer-policy branch June 5, 2020 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Pertaining to developers trying to use Quilkin, e.g. cli interface, configuration, etc kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Client] LB across multiple endpoints?
2 participants