Performance problems with Simple Expression Language in Camel
andr2ot Aug 23, 2013 1:20 PMWe facing a problem with Simple Expression Language as part of our camel routes. The usage of simple is decreasing the performance of the actual route.
We using camel 2.10.0.redhat-60024. Could anybody please confirm if that is a known issue?
I created a show case route to replicate this behavior. I would be happy to commit it all that to github if anybody is interested.
<code>
performance-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<camelContext id="performance" xmlns="http://camel.apache.org/schema/spring">
<route id="inputRoute">
<from uri="dataset:input?preloadSize=10000" />
<to uri="seda:inputQueue" />
</route>
<route id="baseBenchmarkRoute">
<from uri="seda:inputQueue?concurrentConsumers=8" />
<to uri="log://?level=INFO&groupInterval=1000&groupDelay=1000&groupActiveOnly=false" />
<setHeader headerName="value">
<simple>${body.value}</simple>
</setHeader>
<delay>
<constant>10</constant>
</delay>
<inOnly uri="mock:outputQueue" />
</route>
</camelContext>
<bean id="input" class="com.performance.InputDataSet">
<property name="size" value="10000" />
</bean>
</beans>
</code>
InputDataSet.class used to
<code>
public class InputDataSet extends DataSetSupport {
@Override
protected Object createMessageBody(final long messageIndex) {
String description = "name" + messageIndex;
SimplePojo body = new SimplePojo();
body.setValue("" + messageIndex);
body.setDescription(description);
return body;
}
}
</code>
I created test to verify the throughput of this route.
<code>
@RunWith(CamelSpringJUnit4ClassRunner.class)@ContextConfiguration("classpath:performance-test.xml")
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@UseAdviceWith(true)
public class PerformanceTest {
@Autowired
protected ModelCamelContext context;
@EndpointInject(uri = "mock:outputQueue")
protected MockEndpoint mockOutput;
@Test
public void performanceTest() throws Exception {
context.start();
mockOutput.setResultWaitTime(20000); // 10 seconds
mockOutput.expectedMessageCount(10000);
mockOutput.assertIsSatisfied();
}
}
</code>
The average Throughput of this route is around 400 messages per second.
Received: 400 new messages, with total 857 so far. Last group took: 1000 millis which is: 400 messages per second. average: 358.427
After replacing the setHeader with a processor which performs same action the throughput increased to 700 messages per second. Does anybody else experience similar behavior?
We are very suprised with poor performance of Simple Expression Language in camel.