You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have a use case where I read from Jetstream, do some processing over the data, then write it to a different buffer and then ack the read messages.
I'm following two approaches
I send all the data to be written to Jetstream at the same instant, wait for all the messages to be written and then perform the ack. So here we would get N messages to be written at once, and we will invoke a single go-routine for each of them for writing.
I keep sending individual messages to be written and subsequently Acked as i'm receiving the response for them. In this case we have long running routines which would keep looking for any new messages to be written and then send it to jetstream for writing.
Based on the performance comparison for both of them I did not expect to see a difference from jetstream, but on profiling the code I see that the Nats flush time is significantly different.
The time taken for flushing in approach 1 is as follows -
The time for flushing in approach 2 is as follows -
Is this behavior expected? Any pointers on why this would be happening or if I can do some changes in configuration that can help to reduce this flush time
Both the approaches use synchronous publish underneath
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I have a use case where I read from Jetstream, do some processing over the data, then write it to a different buffer and then ack the read messages.
I'm following two approaches
I send all the data to be written to Jetstream at the same instant, wait for all the messages to be written and then perform the ack. So here we would get N messages to be written at once, and we will invoke a single go-routine for each of them for writing.
I keep sending individual messages to be written and subsequently Acked as i'm receiving the response for them. In this case we have long running routines which would keep looking for any new messages to be written and then send it to jetstream for writing.
Based on the performance comparison for both of them I did not expect to see a difference from jetstream, but on profiling the code I see that the Nats flush time is significantly different.
The time taken for flushing in approach 1 is as follows -
The time for flushing in approach 2 is as follows -
Is this behavior expected? Any pointers on why this would be happening or if I can do some changes in configuration that can help to reduce this flush time
Both the approaches use synchronous publish underneath
Beta Was this translation helpful? Give feedback.
All reactions