Flow control and initial / new / threshold permits

Hi. Is it possible to give a little bit more insight on how these properties work?


What I see from code, we get remainingNumberOfPermits as initial_number - threshold.
Each time event is sent, remainingNumberOfPermits is decreased by 1 and when remainingNumberOfPermits == 0, new_permits request is sent.
What is happening between “new_permits requests” ?
What are the optimal values to get max throughput ?

Hi Стас,

we use these 3 settings to prevent to request a single event for each message we receive, as there is some overhead on the messages. Therefore, we send the “permits” in blocks to the server, requesting new messages once the remaining number of permits is below a certain value.

initial-nr-of-permits - the number of permits requested when the connection first starts
nr-of-new-permits - the number of permits granted each time the threshold is reached
new-permits-threshold - the threshold in remaining permits when to ask for new ones.

The best performance is reached when the new-permits-threshold is relatively high. However, this may also cause more “new permits” messages, which increases I/O and requires larger buffers on the client-side to contain all the messages.

In between permit requests, there should be enough messages in the buffer to keep processing until the next batch of messages start arriving.

Hope this helps.

Hi Allard.

Wasn’t those properties about flow control at the client side ?
With your new explanation I started to think the following.

Say we are at defaults: initial-nr-of-permits = 5000, 2500 for nr-of-new-permits and new-permits-threshold.
Client is allowed to send 5000 commands to the axon server, when threshold is reached it is starting to request new permits (2500 in this case) and if
axon server is doing good it will allow to send next 2500 requests, if not it will give minimum amount of allowed commands to be send or zero if it is fully loaded.

Was slightly confused with this statement “we use these 3 settings to prevent to request a single event for each message we receive
Could you please clarify what events are being requested ?

Sorry for the confusion.

Flow control is to prevent flooding the client with messages from the Server. So the client tells the server how many messages it can receive, before the server should stop sending more.

What I meant with the threshold, is that instead of sending a ‘send me one more’ message each time we process one (on the client side), we send a ‘send me 500 more’ message after processing 500.

Hope this helps.


Thanks, got it !