fwrite(): send of 13 bytes failed with errno=32 Broken pipe服務器
fwrite(): send of 21 bytes failed with errno=104 Connection reset by peerfetch
用 rabbitmq 作消息隊列時報上面的錯誤,當消費隊列一啓動,Unacked 瞬間達到好幾百。經查:RabbitMQ服務器在短期內發送大量的消息給Consumer,若是你沒有來得及Ack的話,那麼服務端會積壓大量的UnAcked消息,而Consumer若是來不急處理也會處於假死或程序崩潰。spa
後果就是Consmer崩潰後,UnAcked消息又ReQueue不斷消耗MQ的資源code
解決方案:blog
$connection = new AMQPStreamConnection(HOST, PORT, USER, PASS, VHOST); $channel = $connection->channel(); $channel->queue_declare('qos_queue', false, true, false, false); $channel->basic_qos(null, 10, null); //加上這個就行了 這個10 就是Unacked 裏面的值,表示預先取出多少值來消費 prefetch_count