[erlang-questions] Process overhead

Ulf Wiger <>
Thu Jun 18 09:17:53 CEST 2009

Fredrik Svensson wrote:
> I have a gen_server which handles sessions, and I send messages only
> when the session is active. I am concidering two solutions:
> 1. Starting a gen_fsm for each session, each holding the state of the
> session, and ran as long as the session is active.
> 2. Starting gen_fsm:s only to wait for message replys, then terminate
> and save the session-id in an ets table. Then starting a new gen_fsm
> for each message to handle the responses.

The generic answer is number 1, definitely.

You should have very strong reasons to go with number 2,
and understand what you're getting yourself into. There
are subtle race conditions lurking in the weeds, and you'll
be hard pressed to cover them all.

As has been pointed out, Erlang processes do not use much
extra memory, and hibernate() is there to squeeze it even
more if you really need to.

Ulf W
Ulf Wiger
CTO, Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list