[erlang-questions] process stats

Jachym Holecek freza@REDACTED
Fri Nov 2 18:40:26 CET 2012

# J?zsef B?rces 2012-11-02:
> I am writing an application that runs in the background crunching some
> data and writing result files to the disk. It has a web interface to
> configure what data and how to process. And I was thinking about that
> it would be good to be able to present some stats on the web interface
> about which Erlang processes how much CPU resources used during the last
> second/minute/day/week etc.
> Is there any way to get this kind of info somehow without wasting too
> much resources on the stat collection itself? I do not want it for all
> Erlang processes, only for a well defined subset of them.

You could poll them with erlang:process_info/2 and compile some stats
from that. Memory usage items are quite detailed and self-explanatory,
the 'reductions' item then corresponds to CPU usage (roughly the total
number of function applications evaluated, I think).

This makes sense if your processes are long-lived, if they're just a
bunch of short-lived workers then perhaps it's better if they submit
final usage report on completion?

> eprof/fprof seem to be too heavy: they would take too much system
> resources and they would produce too detailed data for me.
> erlang:system_profile seems to be promising (I have not started playing
> with it) but it has that note in the doc that it is experimental so I am
> a bit afraid of it.

For VM global stats erlang:system_info/1 and erlang:memory/N should be
useful. Same approach as above -- poll them periodically and compute
whatever stats you want to present in the GUI. It probably makes sense
to do the global stats first and leave more detailed accounting for

Not sure about runtime overhead of these...

	-- Jachym

More information about the erlang-questions mailing list