GitHub user necouchman opened a pull request:
https://github.com/apache/incubator-guacamole-client/pull/161
GUACAMOLE-102: Support Connection Load Balancing
Okay, this is a LONG shot, but I've taken a stab at a basic implementation
of a weighted load balancing algorithm in the Guacamole client. This is likely
to need a lot of work before it's actually ready for merging - I'm
acknowledging that up-front :-).
This adds the table column for the connection weight into the DB schema,
the necessary JDBC calls to grab, set, and update connection weight, and then
the updates to the compare function to sort connections based on a "Weighted
Least Connection" algorithm.
The algorithm itself has some nuances that are worth describing. First, I
tried to incorporate as much of what was discussed in the JIRA issue as
possible. Not setting the weight is acceptable, and will result in the
algorithm calculating based on a weight of 1 when no weight is explicitly
assigned. I don't know if this is ideal, but kind of necessary to do something
like this when doing a WLC calculation. Weights of 0 and negative values cause
the connection to be eliminated from the group - the thought is that these
values can be used when updating weights externally/dynamically to denote
systems that have not been polled yet (0) or that are administratively disabled
(-1, etc.). For the purposes of sorting the connections, the 0 and negative
values are also replaced with a 1 so that the compare function works as
expected, but are those connections will later be bypassed by the acquire()
method.
The compare() method now adds one to the number of active connections of
both items during comparison in order to avoid a zero value. The rationale
behind this is that it allows servers with higher weights and zero connections
to be preferred over servers with lower weights and zero connections - without
this addition anything with zero connections will end up basically equivalent
regardless of its configured weight rather than actually being evaluated by
weight.
The overall algorithm was taken from a combination of the LVS wiki page
describing how they do WLC and a Citrix article on WLC connections.
This is a pretty simple initial implementation - I have some goals for
building upon this in the future, but those are probably better discussed on
the JIRA issue and not in this PR.
Fire away...
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/necouchman/incubator-guacamole-client
GUACAMOLE-102
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-guacamole-client/pull/161.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #161
----
commit 01d5fe9c106919f6e26f0d52cf23f95fb200d7c8
Author: Nick Couchman <[email protected]>
Date: 2017-03-19T15:57:28Z
GUACAMOLE-102: Initial addition of connection weight to JDBC authentication
extension
commit ce9c96ee6873ba5c17df086c56a330124c7728bb
Author: Nick Couchman <[email protected]>
Date: 2017-03-19T20:24:56Z
GUACAMOLE-102: Finish adding connection weight attribute.
commit 0e167b3b0259f9f89b2e58392ab6db8039dc5e14
Author: Nick Couchman <[email protected]>
Date: 2017-03-20T10:49:10Z
GUACAMOLE-102: Initial stab at a WLC algorithm.
commit c854951402762f21ab42a19502703a0386547f2b
Author: Nick Couchman <[email protected]>
Date: 2017-03-20T13:06:04Z
GUACAMOLE-102: Tweak algorithm for computing the WLC vlaues.
commit 7f5a7acc562e272e40ed9541fffc2e0b891bf7cb
Author: Nick Couchman <[email protected]>
Date: 2017-03-20T13:55:41Z
GUACAMOLE-102: Remove some extra debugging code, and continue to tweak the
WLC algorithm.
commit a527d398d678858cafec49169cef4e549e5ea238
Author: Nick Couchman <[email protected]>
Date: 2017-03-20T14:50:33Z
GUACAMOLE-102: Continue to work on the load balancing code.
commit 45573730e99e47d064d31b17a401a63644160174
Author: Nick Couchman <[email protected]>
Date: 2017-03-20T18:55:35Z
GUACAMOLE-102: Adding some commentary for changes in the
RestrictedGuacamoleTunnelService class.
commit a4ac17b5c7c33ee7c0cd4574a4e342043c9c02a2
Author: Nick Couchman <[email protected]>
Date: 2017-05-31T19:22:31Z
GUACAMOLE-102: Deal with weights of 0, and properly dispose of connections
with negative weights.
commit 4b7efcd03a137d68fa686f20ea9c710497748d60
Author: Nick Couchman <[email protected]>
Date: 2017-06-01T00:18:25Z
GUACAMOLE-102: Remove redundant iterations through connections.
commit a58fde75c742439ba5bbca908b1a4ab885abbf32
Author: Nick Couchman <[email protected]>
Date: 2017-06-01T01:39:16Z
GUACAMOLE-102: Clean up and simplify WLC sorting code.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---