fhteam / laravel-amqp

AMQP driver for Laravel queue
GNU General Public License v2.0
28 stars 12 forks source link

Publisher disconnecting when rabbitmq server is under load #20

Closed milsanore closed 6 years ago

milsanore commented 6 years ago

RabbitMQ Server: Ubuntu 14.04 LTS RabbitMQ 3.6.15 Erlang R16B03

Publisher: Ubuntu 14.04 LTS PHP 7.1.13 Laravel Framework 5.5.33 fhteam/laravel-amqp v3.0.0

Hi, As always, thanks for the great library. It's the backbone of my distributed Laravel system.

I am starting to push RabbitMQ hard - publishing over 5,000 messages per second. Sometimes I will see the following in the RabbitMQ logs:

=WARNING REPORT==== memory resource limit alarm set on node 'rabbit@myserver'.


Publishers will be blocked until this alarm clears


In my publisher's log I will see a network connectivity error, and then back in the RabbitMQ log:

=WARNING REPORT==== closing AMQP connection client unexpectedly closed TCP connection

So it seems like my publisher is losing it's connection. Judging by the documentation I would expect the publisher to be blocked, but not disconnected, which makes me think that this may be a timeout issue on the publisher's side.

Do you think this is an issue in the laravel-amqp layer, or maybe in the php-amqplib layer, or maybe my app?

Thanks,

EDIT: On a related note, the folks at RabbitMQ extended the AMQP protocol to support client notifications (inlcuding blocked/unblocked). Can the library support these? Thanks

FractalizeR commented 6 years ago

I think you should just adjust memory settings of RabbitMQ. I doubt any library can do something about this. Please read this: https://www.rabbitmq.com/memory.html

This may happen if you use non-persistent queues, where RabbitMQ is ought to keep all messages in memory and runs out of it or, if you use persistent queues, I think the rate at which you send messages may overflow some memory buffer in RabbitMQ because it doesn't call flush() on each and every message. It buffers them and flushes once per some interval.

milsanore commented 6 years ago

Sure, thanks!