[
https://issues.apache.org/jira/browse/CAMEL-5039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13216761#comment-13216761
]
Ashwin Karpe commented on CAMEL-5039:
-------------------------------------
Hi,
Here is a simple and cleaner implementation, I propose. However being random,
the weighted delivery can only be checked in a roundabout way.
The pseudo code shows how I would like to implement the solution. Note that the
final implementation will be more refined and account for many
different/additional ratios (i.e X:Y:Z:A:B:C).
The challenge of course will be the testing aspect of the truly random
distribution and I welcome feedback in this regard.
Please comment...
Cheers,
Ashwin...
---------------------------------------------------------------------------------------
Proposal.
---------
For a given distribution ratio (X:Y:Z:A)
[pseudo_code]
range1 = X
range2 = X+Y
range3 = X+Y+Z
range4 = X+Y+Z+A
random_seed = X+Y+Z+A
selection = random(random_seed);
if (selection <= range1) {
dispatchToRoute1();
} else if (selection > range1) && (selection <= range2) {
dispatchToRoute2();
} else if (selection > range2) && (selection <= range3) {
dispatchToRoute3();
} else if (selection > range1) && (selection <= range2) {
dispatchToRoute4();
}
> Make WeightedRandomLoadBalancer really random
> ---------------------------------------------
>
> Key: CAMEL-5039
> URL: https://issues.apache.org/jira/browse/CAMEL-5039
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Xavier Fournet
> Assignee: Ashwin Karpe
> Attachments: CamelLoadBalancerTest.java, current-impl-result.txt,
> new-impl-result.txt
>
>
> As Mark Harwood explained in last comment of CAMEL-3197 the
> WeightedRandomLoadBalancer is not doing a good load balancing job if some
> weight are a lot bigger than some other weight.
> See in the attached example (current-impl-result.txt), the first and third
> routes are always called at the very beginning of every 50 iterations
> loadbalancing round.
> I propose a modified algorithm that do a more balanced loadbalancing
> (new-impl-result.txt)
> Attached the test program with the proposed implementation.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira