Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dramatiq uses more RabbitMQ connections than necessary #649

Open
WillDaSilva opened this issue Sep 4, 2024 · 3 comments
Open

Dramatiq uses more RabbitMQ connections than necessary #649

WillDaSilva opened this issue Sep 4, 2024 · 3 comments

Comments

@WillDaSilva
Copy link
Contributor

We use RabbitMQ as our Dramatiq broker, and we're always dangerously close to the connection limit (which is 500 in our case). This is because Dramatiq creates a connection in each worker process for each queue we have, and we have a queue per Dramatiq task.

We think Dramatiq can be modified to use fewer connections. According to CloudAMQP's RabbitMQ best practices, you should generally limit connections to one connection per process, and use channels within that connection for per-thread use. Instead of doing this, Dramatiq creates a new connection with a single channel for each RabbitMQ consumer it creates, and it creates a consumer for each queue per process, when it could probably be made to just use one connection which each consumer within a process shares, and then each consumer can just create a channel for itself.

What OS are you using?

Debian 12 (via the official Python Docker image)

What version of Dramatiq are you using?

v1.17.0

@spumer
Copy link

spumer commented Sep 5, 2024

You can use https://github.com/spumer/dramatiq-kombu-broker/
It's implement connection pooling and channel pooling

And soon we are publish video and article about this solution:
https://piterpy.com/talks/d5516075e54d41c68d7d3be0c191b09b/

@spumer
Copy link

spumer commented Oct 4, 2024

Also, you can try to use this: https://github.com/cloudamqp/amqproxy

@spumer
Copy link

spumer commented Nov 19, 2024

Also remoulade (fork of dramatiq) implement thread-safe broker via amqpstorm, channelpool and separate thread for I/O

https://github.com/wiremind/remoulade/blob/adf142467867a99b10dee7d32de2591ceafe8504/remoulade/brokers/rabbitmq.py#L45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants