I am trying to apply some flow control in my application which based on RabbitMQ.
A very narrow brief over my system:
- There are some blue-workers that scan and input directory and publish messages to an exchange.
- There are other red-workers that consume from this exchange (based on routing keys) and do whatever they do with the data and than delete it.
The data that is "stored" in the exchange is quite big and the time that takes to a worker to go over it is noticeable. After some time I am getting a memory warning from RabbitMQ which states that the memory usage is too high and all publishing operations are stopped.
I tried to increase the amount of memory Rabbitmq is using but it just postpone the problem in a few hours (of runtime). I also made the queues disk-based instead of ram-based but my disk got full instead.
Since my input is not that big I can live with a "large" input queue from which the blue-workers read their input. So I thought to try and set some "max length" on the link between the blue-workers and the exchange. I believe that I won't loose anything here since the real bottleneck of my system is the red-workers (by the way I declared the link between the red-workers and the exchange with a prefech_count=2
).
After saying all that... I didn't manage to apply such a max-length :(
I am using Pika
to declare my queues and working with channels.
I read this (https://www.rabbitmq.com/maxlength.html) but didn't manage to implement it in my code and I would like to see an example that uses this max-size flag.