-
Notifications
You must be signed in to change notification settings - Fork 607
Description
Hello.
We're using rabbitmq library version 5 in web applications to publish messages from request. As you may guess it's highly concurrent environment and it's quite common to have 100-500 requests per second sending a message to rabbit.
Trying to update to version 6 of the library (6.2.1 at this time) shows a lot of timeout errors while sending the message. The problem can be reproduced locally and I've attached a simple solution with two projects:
- RabbitMQ (which is using 5.2.0)
- RabbitMQ2 (which is using 6.2.1)
Also I've added simple docker compose file to spin single local rabbitmq node on 127.0.0.11
Each project contains identical code which performs this steps:
- Opens single (static) connection
- Creates exchange "tests" (durable with type = topic)
- Starts 100 parallel tasks trying to publish a message to "test" exchange with publish confirm
Step 3 implemented in 3 different ways and can be switched by passing specific argument when running project:
- (default) always creates new channel for each publish and disposes it
- (per_thread) creates channel per thread (using ThreadStatic)
- (per_thread_with_lock) creates channel per thread (using ThreadStatic) but performs locking so only 1 thread opens up a channel at a time
- (single) only one channel created and every task is under single lock to accessing it
Running all tests on v5 gets me a very good performance - 7-9 msec per message (100 messages total in parallel).
Running all tests on v6 never completed without timeout errors.
Can someone please look into this? Maybe I'm doing something wrong? How to use rabbitmq v6 in high concurrent environment like web?