...
Tip | ||
---|---|---|
| ||
You can configure |
Weighted Round-Robin and Random Load Balancing
Available as of Camel 2.5
In many enterprise environments where server nodes of unequal processing power & performance characteristics are utilized to host services and processing endpoints, it is frequently necessary to distribute processing load based on their individual server capabilities so that some endpoints are not unfairly burdened with requests. Obviously simple round-robin or random load balancing do not alleviate problems of this nature. A Weighted Round-Robin and/or Weighted Random load balancer can be used to address this problem.
The weighted load balancing policy allows you to specify a processing load distribution ratio for each server with respect to others. You can specify this as a positive processing weight for each server. A larger number indicates that the server can handle a larger load. The weight is utilized to determine the payload distribution ratio to different processing endpoints with respect to others.
Tip | ||
---|---|---|
| ||
As of Camel 2.6, the Weighted Load balancer usage has been further simplified, there is no need to send in distributionRatio as a List<Integer>. It can be simply sent as a delimited String of integer weights separated by a delimiter of choice. |
The parameters that can be used are
In Camel 2.5
Option | Type | Default | Description |
---|---|---|---|
roundRobin | boolean | false | The default value for round-robin is false. In the absence of this setting or parameter the load balancing algorithm used is random. |
distributionRatio | List<Integer> | none | The distributionRatio is a list consisting on integer weights passed in as a parameter. The distributionRatio must match the number of endpoints and/or processors specified in the load balancer list. In Camel 2.5 if endpoints do not match ratios, then a best effort distribution is attempted. |
Available In Camel 2.6
Option | Type | Default | Description |
---|---|---|---|
roundRobin | boolean | false | The default value for round-robin is false. In the absence of this setting or parameter the load balancing algorithm used is random. |
distributionRatio | String | none | The distributionRatio is a delimited String consisting on integer weights separated by delimiters for example "2:3:5". The distributionRatio must match the number of endpoints and/or processors specified in the load balancer list. |
distributionRatioDelimiter | String | : | The distributionRatioDelimiter is the delimiter used to specify the distributionRatio. If this attribute is not specified a default delimiter ":" is expected as the delimiter used for specifying the distributionRatio. |
Using Weighted round-robin & random load balancing
- In Camel 2.5
An example using Java DSL:Code Block ArrayList<integer> distributionRatio = new ArrayList<integer>(); distributionRatio.add(4); distributionRatio.add(2); distributionRatio.add(1); // round-robin from("direct:start") .loadBalance().weighted(true, distributionRatio) .to("mock:x", "mock:y", "mock:z"); //random from("direct:start") .loadBalance().weighted(false, distributionRatio) .to("mock:x", "mock:y", "mock:z");
And the same example using Spring XML:
Code Block |
---|
<route>
<from uri="direct:start"/>
<loadBalance>
<weighted roundRobin="false" distributionRatio="4 2 1"/>
<to uri="mock:x"/>
<to uri="mock:y"/>
<to uri="mock:z"/>
</loadBalance>
</route>
|
- As of Camel 2.6
An example using Java DSL:Code Block // round-robin from("direct:start") .loadBalance().weighted(true, "4:2:1") .to("mock:x", "mock:y", "mock:z"); //random from("direct:start") .loadBalance().weighted(false, "4,2,1", ",") .to("mock:x", "mock:y", "mock:z");
And the same example using Spring XML:
Code Block |
---|
<route>
<from uri="direct:start"/>
<loadBalance>
<weighted roundRobin="false" distributionRatio="4,2,1" distributionRatioDelimiter="," />
<to uri="mock:x"/>
<to uri="mock:y"/>
<to uri="mock:z"/>
</loadBalance>
</route>
|
Using this Pattern
Include Page | ||||
---|---|---|---|---|
|