camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: LoadBalancer seems to be doing some sort of throttling
Date Fri, 22 May 2015 05:48:33 GMT
Hi

Yes your custom code is compiled java code, where as when using simple
with an OGNL expression, eg body.partionKey then Camel need to invoke
the method using reflection and hence the overhead.

You can likely use groovy or mvel as the expression and do some code like:

.sticky().groovy("exchange.getBody(EventData.class).getPartitionKey()")

As they would be able to compile this on the fly and run it faster


On Fri, May 22, 2015 at 6:02 AM, apara <apara@standardset.com> wrote:
> So, it turns out that the processing of simple expressions is apparently
> somewhat slow (my camel routes are currently handling 2300 events/second) so
> each message is taking milliseconds to get through the pipelines.  If the
> load balancing calculation takes too long it cannot keep the pipelines full.
>
> I replaced the sticky(...) specification with my own code and things are
> flying:
>
>         .loadBalance(
>             new QueueLoadBalancer() {
>                 @Override
>                 protected Processor chooseProcessor(final List<Processor>
> processors, final Exchange exchange) {
>                     //Get the partition key
>                     //
>                     final String
>                         partitionKey =
>                             exchange
>                                 .getIn()
>                                 .getBody(
>                                     EventData.class
>                                 )
>                                 .getPartitionKey();
>
>                     //Calculate the position
>                     //
>                     final int
>                         size = processors.size(),
>                         index = (partitionKey.hashCode() % size + size) %
> size;
>
>                     //Return the processor to use
>                     //
>                     return
>                         processors
>                             .get(
>                                 index
>                             );
>                 }
>             }
>         )
>
> It's amazing the kind of issues you start to find at these processing
> speeds.  I am quite satisfied with Camel's raw processing speed when it
> comes to core message routing.
>
> -AP_
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/LoadBalancer-seems-to-be-doing-some-sort-of-throttling-tp5767401p5767406.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message