does not work --max-prefetch=1 #389
Answered
by
s3rius
Randommist
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
s3rius
Dec 22, 2024
Replies: 1 comment 1 reply
-
For me, the problem was solved by using RabbitMQ with the qos parameter. It turns out that it is responsible for the amount of prefetch. broker = (
AioPikaBroker(qos=1)
.with_result_backend(RedisAsyncResultBackend(redis_url="redis://localhost:6379"))
) but I still don't understand what --max-prefetch does then, since in my tests it didn't make any difference |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! Here's an explanation of why this happens:
This issue is specific to RabbitMQ's underlying implementation and the aio-pika library. While it's not necessarily a problem, it might break some expectations.
Essentially, the
prefetch-count
parameter creates a queue at the worker level, limiting the number of messages coming from the broker. However, aio-pika prefetches messages before they are given to the worker. As a result, you may still see prefetched messages even if themax-prefetch
parameter is set to 1.Updating the
qos
settings will instruct aio-pika not to prefetch messages and to delegate the task to the taskiq worker entirely.Hope that has helped.