[QUESTION] How is your library asynchronous? #1077
Replies: 3 comments
-
The library is asynchronous in the sense that it is compatible with asyncio. The behavior you show above is standard for a Kafka consumer. If you want to process a lot of data and don't care about order, one thing you can do is use multiple consumers, all with the same group ID. Then each consumer will see a subset of messages. If one message is slow to download, that will not hold up processing of other messages by other consumers (but it will hold up processing of additional messages by the consumer handling the slow message). I have no idea if it's possible for one consumer to start a download of multiple messages at the same time. |
Beta Was this translation helpful? Give feedback.
-
Can you develop faust app in such way that you have multiple kafka consumers -> single faust processor -> multiple kafka producers? |
Beta Was this translation helpful? Give feedback.
-
I think the syntax is misleading here. The async for waits for the next message which will sometimes require a call to brokers for the next batch of messages. If you want to parse multiple messages in parallel, you would yield in your handling for the consumption of the message. Details on fetching and prefetching are in docs |
Beta Was this translation helpful? Give feedback.
-
I just tried the sample code for AIOKafkaConsumer from your github page on a topic with 1 partition. At each iteration I output msg.offset, and the offsets appear in order. So, how is this library even asynchronous? I don't understand what's asynchronous about it.
Here's the code that I ran with ip and topics omitted:
I am not an advanced python user, I use scala, but from what I understand each iteration of the for loop has to create an async task for reading a kafka message.
Now imagine the message at offset 0 to be something that needs 1 hour to download, and the message at offset 1 takes 1 second to download, the callback for message 1 should be executed before the callback for message 0, and they are supposed to come out of order. But why do they come in order?
Beta Was this translation helpful? Give feedback.
All reactions