Closed Dieterbe closed 7 years ago
Your code seems to rely on the automatic acknowledgement mode and no prefetch (see tutorial 2. Therefore RabbitMQ will deliver to it as fast as possible and there is no way to for consumer to throttle the rate.
Have you considered using manual acknowledgement and a bounded prefetch, say, 200 or 300?
Unless you are cancelling consumers or closing channels, #264 is unrelated. That issue only leaks memory when there are in flight messages (the higher the prefetch the bigger the effect) when a consumer is cancelled and you don't explicitly drain the consumer delivery chan.
thanks for your help, if it looks like the causes of the problem are all on our side (seems to be the case), feel free to close this ticket
Hello amqp maintainers, I run an open source project (https://github.com/graphite-ng/carbon-relay-ng) that uses this library, and one of my users is running into a memory leak problem:
the user also reported:
our amqp consumption routine is single threaded. (see https://github.com/graphite-ng/carbon-relay-ng/blob/fa4a07caa9a9f85463441cfb66d615bc475a320b/cmd/carbon-relay-ng/carbon-relay-ng.go#L193 and https://github.com/graphite-ng/carbon-relay-ng/blob/fa4a07caa9a9f85463441cfb66d615bc475a320b/input/amqp.go#L33 ) so my hypothesis is this: as long as we can handle the ingest volume, no problem. but once the volume is too high, the amqp consumption goes up to 100% cpu and maxes out a single cpu, and the amqp library consumes faster than we can, and that allocates all that memory. and the 36% cpu is just other stuff the relay does.
note this was produced with amqp library d75c3a341ff43309ad0cb69ac8bdbd1d8772775f dated 2017-02-3T13:40:38Z, I just updated the carbon-relay-ng project to use the latest amqp master (https://github.com/graphite-ng/carbon-relay-ng/commit/3e876644819001f0ad21ac0bc427a5eff9cb7332) , would be nicer to reproduce with that, though i didn't see any changes obviously related to this code.
now, the route in the relay was configured like so:
as for how that translates into the options passed in to the amqp library, it's probably easiest/clearest if i just link you to our code at https://github.com/graphite-ng/carbon-relay-ng/blob/fa4a07caa9a9f85463441cfb66d615bc475a320b/input/amqp.go (StartAMQP and consumeAMQP functions)
PS this issue looks somewhat similar to #149 and #264 but i'm not sure.
personally i know little of rabbitmq/amqp (in fact this functionality was contributed by others but I'm trying to support it) so i'm not even sure if we're just misusing the library or not, but to you it might be obvious..
thanks!