Throughput logging

Camel's Log Component includes the ability to see the average throughput of messages flowing through your route. It is not a perfect measure, though it will help you tune your route to reach the throughput you are hoping for. It can also help you to validate that any Throttle EIPs (see the Throttler – restricting the number of messages flowing to an endpoint recipe in Chapter 2, Message Routing) you put in place are doing the right thing.

This recipe will show you how to use the Log Component to report (log) the average message flow throughput of your integration route.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.monitoring.logthroughput package. The Spring XML files are located under src/main/resources/META-INF/spring and prefixed with logthroughput.

How to do it...

Use the groupSize attribute as a part of the log: endpoint URI.

In the XML DSL, this is written as:

<route>
  <from uri="direct:start"/>
  <to uri="log:throughput?groupSize=10"/>
  <to uri="mock:result"/>
</route>

In the Java DSL, the same route is expressed as:

from("direct:start")
  .to("log:throughput?groupSize=10")
  .to("mock:result");

The resulting log entry should look something like the following:

INFO  throughput  - Received: 10 messages so far. Last group took: 913 millis which is: 10.953 messages per second. average: 10.953

How it works...

The Log Component will log a message every time it sees the specified number of messages flow past (groupSize), and it will report the amount of time since the last group of messages as well as the average throughput (messages per second).

Analyzing the performance and throughput of any system using tools such as the Log Component's throughput reporting is a bit of an art form. You will need to mentally factor into the reported numbers aspects such as how your route started, how and when the first message was sent to it, what else is running on your test system that may be impacting your test, and so on. This tool provides you with one more measurement that can help you better understand your system.

There's more...

You can also have the Log Component report average throughput during regular time intervals using the groupInterval option specified in milliseconds. The groupDelay option allows you to say how many milliseconds to wait before starting to track the first group—allowing you to "warm up" your routes.

In the XML DSL, this is written as:

<route>
  <from uri="direct:start"/>
  <to uri="log:a?groupInterval=1000&amp;groupDelay=500"/>
  <to uri="mock:result"/>
</route>

In the Java DSL, the same route is expressed as:

from("direct:start")
  .to("log:a?groupInterval=1000&groupDelay=500")
  .to("mock:result");

Here is a sample of the type of output you would see from the preceding configuration:

INFO  a  - Received: 10 new messages, with total 15 so far. Last group took: 1000 millis which is: 10 messages per second. average: 10.128

The log entry will report several pieces of information:

  • How many new messages this endpoint has received since its last report in the log, and a running total count of messages seen since the log endpoint was started
  • How long in milliseconds since the last report, and the window average throughput—number of new messages divided by time since last report
  • Average throughput for all messages since the log endpoint was started—in other words, since you started your route

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.210.91