Parallel async threads #301
-
Hey there, I have a topic with 20 partitions, which I have created a stream from where i make a ForeachAsync. But I've found that the messages in the for each is processed sequentially. So when if an async calls takes 5 seconds, then it will take 5 seconds before the next message is processed. This is despite ParallelProcessing set to true and MaxDegreeOfParallelism set to default. So my question is the following: Is it possible to make the External stream thread parallel while still respecting sequential processing per kafka key. If so what am I missing? Best regards |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hey @okomen-foreflight, Today ForeachAsync processed sequentially the messages, because let's suppose the processing is really asynchronous, I can commit a newer offset before having the return of an oldest offset. And in case of the oldest offset fail, the message is already committed. Btw, |
Beta Was this translation helpful? Give feedback.
-
Hey @LGouellec Kafka offsets are commited per partition not per topic, so if I have 20 partitions and 20 stream threads, it should be possible to allow ForeachAsync to run in parallel with a degree of 20 🤔 |
Beta Was this translation helpful? Give feedback.
-
Hi @okomen-foreflight , Please find bellow the threading model : In other words, if you have 20 partitions with 20 stream threads, you have 1 partition per thread = 1 consumer per partition, the topology isn't shared across all your threads.
|
Beta Was this translation helpful? Give feedback.
Hey @okomen-foreflight,
Today ForeachAsync processed sequentially the messages, because let's suppose the processing is really asynchronous, I can commit a newer offset before having the return of an oldest offset. And in case of the oldest offset fail, the message is already committed.
But I understand what you mean, maybe I can add another parameter to allow really asynchronous processing, but you assume that you can loose messages.
Btw,
ParallelProcessing
andMaxDegreeOfParallelism
is only used for the classic DSL.