I've setup rabbitmq with default config both on my pc and server and noticed a strange behavior on rabbitmq publish rate, no matter how fast i publish messages to rabbitmq the publish rate stays at 12/s both on my pc and the server while these two systems are quite different on the amount of ram and cpu!
For testing purpose i've written a super simple code that published messages to a queue on rabbitmq and again i can see the 12/s publish rate!
i think this is ridiculously low and the publish rate must be way much higher.
I've tested both durable and transient exchanges and messages but the result was the same.
How can i increase the publish rate?
Here is the code:
<?php
for($i=1;$i<20000;$i++){
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->exchange_declare('test', 'direct', false, false, false);
$msg = new AMQPMessage('test '.$i);
$channel->basic_publish($msg, 'test');
$channel->close();
$connection->close();
}
?>
Avoids creating
connection
,channel
andexchange
per iteration. Instead creates them before the iteration and closes them after the loop.They are costly operations (especially
connection
andchannel
).connection
andchannel
should be created and reused.