Doc rabbitmq 内存使用问题

问题描述

[root@osc /]# /usr/local/rabbitmq-3.6.5/sbin/rabbitmqctl status
Status of node rabbit@osc ...
[{pid,162150},{running_applications,[{rabbitmq_top,"RabbitMQ Top","3.6.5"},{rabbitmq_management,"RabbitMQ Management Console",{rabbitmq_management_agent,"RabbitMQ Management Agent",{rabbitmq_web_dispatch,"RabbitMQ Web dispatcher",{webmachine,"webmachine","1.10.3"},{mochiweb,"MochiMedia Web Server","2.13.1"},{inets,"INETS  CXC 138 49","6.3"},{ssl,"Erlang/OTP SSL application","8.0"},{public_key,"Public key infrastructure","1.2"},{amqp_client,"RabbitMQ AMQP Client",{Syntax_tools,"Syntax tools","2.0"},{compiler,"ERTS  CXC 138 10","7.0"},{asn1,"The Erlang ASN1 compiler version 4.0.3","4.0.3"},{crypto,"CRYPTO","3.7"},{rabbit,"RabbitMQ",{ranch,"Socket acceptor pool for TCP protocols.","1.2.1"},{os_mon,"CPO  CXC 138 46","2.4.1"},{mnesia,"MnesIA  CXC 138 12","4.14"},{rabbit_common,[],{xmerl,"XML parser","1.3.11"},{sasl,"SASL  CXC 138 11","3.0"},{stdlib,{kernel,"5.0"}]},{os,{unix,linux}},{erlang_version,"Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:12:12] [async-threads:192] [hipe] [kernel-poll:true]\n"},{memory,[{total,2149246176},{connection_readers,2980888},{connection_writers,316032},{connection_channels,1040720},{connection_other,2950312},{queue_procs,2395096},{queue_slave_procs,0},{plugins,5075776},{other_proc,14218200},442952},{mgmt_db,10889752},{msg_index,149160},{other_ets,2904120},{binary,2064189840},<--------- 2GB???? why? queues is only use 2.7M
      {code,24809744},{atom,1033401},{other_system,15850183}]},{alarms,[]},{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},{vm_memory_high_watermark,0.4},{vm_memory_limit,13456659251},{disk_free_limit,50000000},{disk_free,215603683328},{file_descriptors,[{total_limit,63900},{total_used,128},{sockets_limit,57508},{sockets_used,123}]},{processes,[{limit,1048576},{used,1892}]},{run_queue,{uptime,28157},{net_ticktime,60}}]

二进制文件太高了 所以我关注https://www.rabbitmq.com/memory-use.html#breakdown-binaries

/usr/local/rabbitmq-3.6.5/sbin/rabbitmqctl eval 'recon:bin_leak(10).'
Error: {undef,[{recon,bin_leak,"\n",{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,670}]},{rpc,'-handle_call_call/6-fun-0-',5,"rpc.erl"},187}]}]}
  1. 如何释放内存?队列使用较少约 2.7MB 内存,但二进制文件使用 2GB。 (内存泄漏?)
  2. 为什么这个 /usr/local/rabbitmq-3.6.5/sbin/rabbitmqctl eval 'recon:bin_leak(10).'命令失败?
  3. plungin

2021/3/4 更新

两个相同的环境
rabbitmq 3.6.15 erlang 20
3.6.15
二进制仅使用 1.8M
rabbitmq 3.8.14 erlang 23
3.8.14
二进制使用 1.4G \

Total memory used: 0.1179 gb
Calculation strategy: RSS
Memory high watermark setting: 0.4 of available memory,computed to: 6.6984 gb

binary: 1.4598 gb (91.43 %) 1. <----- why this one > total memory?
allocated_unused: 0.037 gb (2.31 %)
code: 0.0282 gb (1.77 %)
other_proc: 0.0236 gb (1.48 %)
other_system: 0.017 gb (1.06 %)
plugins: 0.0127 gb (0.8 %)
mgmt_db: 0.0037 gb (0.23 %)
other_ets: 0.0036 gb (0.23 %)
connection_other: 0.0032 gb (0.2 %)
connection_readers: 0.0025 gb (0.16 %)
queue_procs: 0.0019 gb (0.12 %)
atom: 0.0015 gb (0.09 %)
metrics: 0.0007 gb (0.04 %)
connection_channels: 0.0006 gb (0.03 %)
mnesia: 0.0004 gb (0.02 %)
connection_writers: 0.0001 gb (0.01 %)
quorum_ets: 0.0 gb (0.0 %)
msg_index: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)
reserved_unallocated: 0.0 gb (0.0 %)

2.为什么 rabbitmq 3.6.15 二进制文件比 rabbitmq 3.8.14 小

3.rabbitmqctl eval 'recon:bin_leak(10).'
它可以是 exec,但二进制文件仍然保持相同的级别从不减少...

解决方法

您使用的是非常旧的 RabbitMQ 版本 (rabbitmq-3.6.5)。

调用 rabbitmqctl eval 'recon:bin_leak(10).' 可从 RAbbitMQ >= 3.70 获得。

我建议使用最新版本的 RabbitMQ>= 3.8.14。

编辑:

命令 rabbitmqctl eval 'recon:bin_leak(10). 显示有(可能)泄漏的进程,它不会释放内存。

您需要按照此处 https://www.rabbitmq.com/memory-use.html 的所有步骤操作并提供更多信息,否则很难说。