You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Richard Morgan <ri...@gmail.com> on 2013/07/25 09:44:21 UTC

Throttling - messages processed per time period exceeding limit

Hello,
I have a camel route within which I am using throttling to limit the number
of requests sent per time period to my endpoint.
Here is a snippet of my route:
<route id="sendSms" errorHandlerRef="smsDeadLetterErrorHandler">
	<from uri="direct:sendSms"/>
	<throttle timePeriodMillis="10000">
		<constant>2</constant>
etc. etc
        <to uri="some uri in here"
        </throttle>

With this I would expect a maximum of 2 messages to be sent every 10
seconds.

However, what I do see is the following:

1. Send in 5 messages to direct:sendSms
2. In the first 10 second block 2 messages are processed (as expected)
3. In the second 10 second block 2 messages are processed (as expected)
4. In the third 10 second block 1 message is processed (as expected)
5. Then I send in another 5 messages to direct:sendSms
6. Now in the next 10 second block 3 messages are processed, which is not as
expected
7. In the next 10 second block the remaining 2 messages are processed.
Then I can repeat steps 1-7 with the same behaviour.

I have changed the timePeriodMillis and maximumRequestsPerPeriod to various
values and see similar behaviour to above. The throttling seems to be
remembering how many messages were processed in the last time period and
using any 'spaces' that weren't used in the current time period.

Is this expected behaviour? Has anyone else seen this sort of thing?

I am using Camel version 2.10.4.

Here is another example, with timePeriodMillis = 10000 and
maximumRequestsPerPeriod = 5:
1. Send in 7 messages to direct:sendSms
2. In the first 10 second block 5 messages are processed (as expected)
3. In the second 10 second block 2 messages are processed (as expected, but
space for 3 more?)
4. Then I send in another 7 messages to direct:sendSms
5. Now in the next 10 second block 7 messages are processed, which is not as
expected (the 5 it is allowed plus 2 in the gaps left from the previous time
period?)
6. Then I send in another 7 messages to direct:sendSms
7. In the next 10 second block 6 messages are processed (the 5 it is allowed
plus 1 from the space still left from 2 time periods ago?)
8. In the next time period the remaining 1 message is processed (but space
for 4 more?)
9. Then I send in another 7 messages to direct:sendSms 
10. In the next period 7 messages are processed (5 plus 2 from the 4 spaces
from last period?)
11. Then I send in another 7 messages to direct:sendSms 
12. In the next period 7 messages are processed (5 plus 2 from the 4 spaces
from last but one period?)
This seems to be the end of the cycle. Steps 1-12 can now be repeated with
the same results.

Note that this behaviour does not seem to be dependent on the time left
between submitting a batch of requests, i.e. in the previous example I can
wait as long as I like between steps 3 and 4 or steps 5 and 6 etc and I see
the same behaviour.

Thanks in advance for any ideas.

Richard.





--
View this message in context: http://camel.465427.n5.nabble.com/Throttling-messages-processed-per-time-period-exceeding-limit-tp5736259.html
Sent from the Camel - Users mailing list archive at Nabble.com.