postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

Channels are not deleted when a queue is deleted #85

Open michaelplaing opened 12 years ago

michaelplaing commented 12 years ago

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.

skrat commented 12 years ago

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 commented 12 years ago

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

jameskeane commented 11 years ago

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 :)

axelson commented 10 years ago

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.