MongooseIM icon indicating copy to clipboard operation
MongooseIM copied to clipboard

Profiling CPU and memory for mongooseim installation.

Open jaspreet-android opened this issue 3 years ago • 2 comments

MongooseIM version: 3.6.0 Installed from: source Erlang/OTP version: 22x

Our mongooseim set up is taking more CPU and memory and we need to find out which process is taking more CPU. When we search etop can help to find the issue : Erlang -- etop (http://erlang.org/doc/man/etop.html)

But when we tried to run with debug mod it does not work.

mongooseimctl debug 
(mongooseim@mongooseim-02)1> etop:start().
** exception error: undefined function etop:start/0

when tried from erl shell on the system then it does not connect.

etop:start([{node, mongooseim@mongooseim-c01}]).
** exception error: an error occurred when evaluating an arithmetic expression
     in operator  -/2
        called as mongooseim@mongooseim - c01

jaspreet-android avatar Jul 01 '21 13:07 jaspreet-android

It worked for me in following ways, closing issue.

/mongooseim# erl -sname mynod  
Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V10.4  (abort with ^G)
(mynod@mongooseim-c01)1>  erlang:set_cookie(node(), ejabberd).
true
(mynod@mongooseim-c01)2> etop:start([{node,'mongooseim@mongooseim-c01'}]).

========================================================================================
 'mongooseim@mongooseim-c01'                                               10:12:49
 Load:  cpu         0               Memory:  total      276739    binary      15145
        procs    1488                        processes  224627    code        18831
        runq        1                        atom         1001    ets          5493

Pid            Name or Initial Func    Time    Reds  Memory    MsgQ Current Function
----------------------------------------------------------------------------------------
<8828.242.0>   exometer_admin            52   82978  489944       0 gen_server:loop/7   
<8828.51.0>    rex                       29   69357   10084       0 gen_server:loop/7   
<8828.748.0>   'wpool_pool-mongoose      29   11308    2732       0 gen_server:loop/7   
<8828.58.0>    net_kernel                26  689047    7140       0 gen_server:loop/7   
<8828.474.0>   mnesia_controller         23  243723    8900       0 gen_server:loop/7   
<8828.640.0>   supervisor:cqerl_cli      23   21602   92992       0 gen_server:loop/7   
<8828.744.0>   'wpool_pool-mongoose      17   23842   92932       0 gen_server:loop/7   
<8828.182.0>   cqerl                     16   57369   94664       0 gen_server:loop/7   
<8828.989.0>   mysql_conn:init/1         1331255327   26480       0 gen_server:loop/7   
<8828.0.0>     init                      11   17957   21548       0 init:loop/1         
========================================================================================

jaspreet-android avatar Jul 02 '21 10:07 jaspreet-android

https://drive.google.com/file/d/1d40FWgw3_wwQjkDYinsNuL5lKoW70Kii/view?usp=sharing

I found mysql is called more and using more Reds in production and hence more CPU. How can I find out which mod is calling more queries?

jaspreet-android avatar Jul 09 '21 19:07 jaspreet-android

To find out which module is calling the queries, you can try to gather data for specific modules with Erlang Doctor. Use with caution, especially in production env. I am closing this one for now.

chrzaszcz avatar Apr 26 '23 07:04 chrzaszcz