Elixir / Erlang: How to find the source of high CPU usage?

My Elixir application uses about 50% of the processor, but it really should use only <1%. I'm trying to figure out what causes high CPU usage and I'm having problems.

In the remote console, I tried

  • List all processes with Process.list
  • Looking at process information with Process.info
  • Sort processes by number of cuts
  • Sort processes by message queue length

Message queues are all close to 0, but the number of abbreviations is very large for some processes. Processes with many abbreviations are called

  • : file_server_2
  • ReactPhoenix.ReactIo.Pool
  • : code_server

(1) and (3) are present in my other applications, so I feel it should be (2). I'm stuck here. How can I go further and find out why (2) uses so much CPU?

I know that ReactPhoenix uses react-stdio . Considering top, response-sdtio does not use any resources, but the beam does.

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        87 53.2  1.2 2822012 99212 ?       Sl   Nov20 580:03 /app/erts-9.1/bin/beam.smp -Bd -- -root /app -progname app/releases/0.0.1/hello.sh -- -home /root -- -noshell -noshell -noinput -boot /app/
root     13873  0.0  0.0   4460   792 ?        Rs   13:54   0:00 /bin/sh -c deps/react_phoenix/node_modules/.bin/react-stdio

I have seen in https://stackoverflow.com/a/168449/ ... that stdin can cause resource problems, but I'm not sure if this applies here. In any case, any help would be greatly appreciated!

+4
source share
1 answer

Have you tried etop?

iex(2)> :etop.start

========================================================================================
 nonode@nohost                                                             14:57:45
 Load:  cpu         0               Memory:  total       26754    binary        143
        procs      51                        processes    8462    code         7201
        runq        0                        atom          292    ets           392

Pid            Name or Initial Func    Time    Reds  Memory    MsgQ Current Function
----------------------------------------------------------------------------------------
<0.6.0>        erl_prim_loader          '-'  458002  109280       0 erl_prim_loader:loop
<0.38.0>       code_server              '-'  130576  196984       0 code_server:loop/1  
<0.33.0>       application_controll     '-'   58731  831632       0 gen_server:loop/7   
<0.88.0>       etop_server              '-'   58723  109472       0 etop:data_handler/2 
<0.53.0>       group:server/3           '-'   19364 2917928       0 group:server_loop/3 
<0.61.0>       disk_log:init/2          '-'   16246  318352       0 disk_log:loop/1     
<0.46.0>       file_server_2            '-'    3838   18752       0 gen_server:loop/7   
<0.51.0>       user_drv                 '-'    3720   13832       0 user_drv:server_loop
<0.0.0>        init                     '-'    2559   34440       0 init:loop/1         
<0.37.0>       kernel_sup               '-'    2093   58600       0 gen_server:loop/7   
========================================================================================

http://erlang.org/doc/man/etop.html

+12
source

Source: https://habr.com/ru/post/1689629/


All Articles