in DevOps

Seeing RabbitMQ memory usage

While working in our RabbitMQ environment this week, we noticed that there was a large, unexplained amount of memory in use by RabbitMQ that we couldn’t account for by normal queue and message use. One of the first tools we use when poking around Erlang and RabbitMQ is to do a memory dump.

$ sudo  rabbitmqctl eval 
     lists:sort([{process_info(Pid, memory), Pid, 
     process_info(Pid)} || Pid <- processes()])), 1).'

This command is evaluated directly into the running erlang instance within our RabbitMQ and dumps the top memory users from largest to smallest. In the above case, we're telling erlang to show us the single top user of memory. You can change the 1 to any positive number you like to get more and more erlang processes returned to evaluate the memory usage of.

This produces something like the following:


I don't know what all of the bits mean yet, but we can point out a few useful things to look at. A good reference on what is being returned can be found in the Erlang documentation for process_info/2

  • memory - the current amount of memory in use by this erlang process. This directly effects the size of the RabbitMQ process size in the OS.
  • <4865.28344.41> - the erlang pid inside the erlang kernel
  • current_function - the function call currently running in the process
  • registered_name - (Note: note seen above). this is the name of the process associated with this memory. If the process isn't named, this won't show up in the output
  • status - What the process is currently doing. It can be something like exiting, garbage_collecting, waiting, running, runnable, or suspended.
  • messages - messages associated with this process.
  • dictionary -

There's more than this, so you should definitely look at the erlang docs to figure out what's going on here, but this should get you started in understanding what memory usage is for your RabbitMQ environment.

Travis Campbell
Staff Systems Engineer at ghostar
Travis Campbell is a seasoned Linux Systems Engineer with nearly two decades of experience, ranging from dozens to tens of thousands of systems in the semiconductor industry, higher education, and high volume sites on the web. His current focus is on High Performance Computing, Big Data environments, and large scale web architectures.