Replies: 1 comment
-
Pika is not thread-safe. There are examples in this repository. Here is one that shows how to consume and process messages on their own threads - https://github.com/pika/pika/blob/main/examples/basic_consumer_threaded.py I realize that's a little different than what you are asking. The first thing I recommend in your case is to try using 1000 connections and then benchmark your environment. Have you tried that? 1000 connections is not that many for RabbitMQ running on modern hardware. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
amqp has not only the concept of connection, but also the concept of channel. As I understand it, the channel concept was introduced to allow multiple threads or concurrent threads to share a connection, so that the connection can be multiplexed. For example, if you have a process with 10 threads, you can just create an amqp connection, and then create 10 channels on that amqp connection, so that each thread can hold a separate channel to achieve concurrency and not conflict with each other.
For example, if I have 100 processes, each of which has 10 threads, and if each thread holds a separate amqp connection, the rabbitmq sevrer will need to maintain a total of 1000 amqp connections, which is a lot of pressure, but if you can implement a "multi-threaded or concurrent sharing of a connection to achieve connection multiplexing", then for rabbitmq sevrer need to maintain a total of 100 amqp connection, the pressure is smaller!
How to use pika to achieve "multiple threads or concurrent threads share a connection to multiplex the connection"? Is there a code sample for this? I need a producer code sample and a consumer code sample.
Beta Was this translation helpful? Give feedback.
All reactions