node-amqp icon indicating copy to clipboard operation
node-amqp copied to clipboard

Channels are not deleted when a queue is deleted

Open michaelplaing opened this issue 12 years ago • 4 comments

One of my apps handles thousands of clients, creating and deleting queues for them. It maintains a single connection with rabbitmq for this purpose. When a queue is deleted its channels remain, causing channels to accumulate. The connection is always busy and cannot be recycled. A connection per client would overcome other resources, I believe.

michaelplaing avatar Mar 27 '12 14:03 michaelplaing

I might be facing the same issue. I noticed that RabbitMQ memory usage is steadily increasing without any change to load (no we didn't get 300% more popular and more users :( . Same number of queues and messages, so I checked number of channels and I've tens of thousands of channels. After restarting my node app, they disappeared and mem. usage dropped from 700M to 200M. Using this code: https://github.com/skrat/celery.js/blob/master/celery.js

skrat avatar May 01 '12 11:05 skrat

Nice to have you back :) I've bee looking into this myself, but without much success so far.

skrat avatar May 21 '12 15:05 skrat

I believe you are running into the same problem as I was, the problem is to do with node-amqp not properly closing channels on error as in #136.

I have a work flow that was very 404 heavy, and would accumulate tens of thousands of channels every few hours, eating memory and destroying our servers. After implementing the fix in #137, we have seen no issues.

Good luck :)

jameskeane avatar Oct 15 '12 03:10 jameskeane

I know this is an old issue but it's still open so I'm going to reply.

I just dealt with this in my code. There are a couple options. If you're correctly unsubscribing from the queue you can set closeChannelOnUnsubscribe to true (defaults to false).

closeChannelOnUnsubscribe : a boolean when true the channel will close on unsubscribe, default false.

Or you can call close on the channel instead of unsubscribe (but beware if you have multiple consumers for the queue). There's probably a way to close a channel that you unsubscribed to but I haven't spent the time to figure it out.

axelson avatar Aug 18 '14 21:08 axelson