RabbitMQ提供rabbitmqctl status命令用来查看rabbitmq消耗内存的情况,这是在本机上执行的结果:
[{pid,11911},
{running_applications,
[{rabbitmq_management_visualiser,"RabbitMQ Visualiser","3.3.5"},
{rabbitmq_tracing,"RabbitMQ message logging / tracing","3.3.5"},
{rabbitmq_management,"RabbitMQ Management Console","3.3.5"},
{rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"},
{rabbit,"RabbitMQ","3.3.5"},
{os_mon,"CPO CXC 138 46","2.2.7"},
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"},
{webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"},
{mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"},
{amqp_client,"RabbitMQ AMQP Client","3.3.5"},
{xmerl,"XML parser","1.2.10"},
{inets,"INETS CXC 138 49","5.7.1"},
{mnesia,"MNESIA CXC 138 12","4.5"},
{sasl,"SASL CXC 138 11","2.1.10"},
{stdlib,"ERTS CXC 138 10","1.17.5"},
{kernel,"ERTS CXC 138 10","2.14.5"}]},
{os,{unix,linux}},
{erlang_version,
"Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:30] [kernel-poll:true]\n"},
{memory,
[{total,67385688},
{connection_procs,5408},
{queue_procs,5408},
{plugins,611776},
{other_proc,9372568},
{mnesia,64360},
{mgmt_db,50248},
{msg_index,34160},
{other_ets,1131704},
{binary,33200},
{code,17757687},
{atom,1619705},
{other_system,36699464}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"0.0.0.0"}]},
{vm_memory_high_watermark,0.8},
{vm_memory_limit,1573470208},
{disk_free_limit,1000000000},
{disk_free,10575826944},
{file_descriptors,
[{total_limit,65435},
{total_used,3},
{sockets_limit,58889},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,187}]},
{run_queue,0},
{uptime,526}]
执行结果中memory部分就是当前内存的消耗情况,可以清楚地了解到总的内存消耗以及分布情况,主要细分成了以下几个类别:
这部分主要包含了连接和通道(channel)所消耗的内存,也包含了SSL系统所使用的内存。
队列占用的内存指的是队列进程消耗的,并不包含消息体(在二进制中)。当内存不足时,这部分的内存将交换到磁盘上。
插件使用的内存不包含连接rabbit服务器的Erlang客户端和数据库所占用的部分,通常包含像一些协议插件如STOMP和MQTT。
除了上面所提到的以外的进程所消耗的部分,这里的进程是erlang虚拟机中的概念,最近被GC回收的内存会展现在这里。
Mnesia保存了一份磁盘上的数据拷贝到内存,意味着当有大量队列、交换机、绑定、用户信息或虚拟主机时会消耗大量的内存。
保存了所有消息的索引,包括那些被交换到磁盘上的消息。
前提是启用了管理插件,在集群中它只会出现在一个节点中。
除了上面三个集合以外的内存表。
erlang虚拟机所使用的共享二进制数据,消息体的内存消耗包含在这部分。
代码所消耗的内存,一般为常量。
atoms消耗的内存,一般为常量。
Erlang所消耗的其他内存,比如可用文件描述符的统计。