[erlang-questions] Process overhead
Wed Jun 17 16:10:41 CEST 2009
I have no clue on the specific memory and CPU overhead of each process, but
Erlang was designed to provide very little overhead for processes.
Scenario 1 is what Erlang is designed for and personally I have had no
issues with using that approach in real life.
Scenario 2 is kind of like adding some context switching using ETS and I
cannot see how that can be more efficient than keeping some processes alive
(which will be suspended intelligently by the runtime). The only certain
thing you will get with this would be extra code, i.e., more to maintain and
understand, but if you are paid the lines of code then by all means!
On Wed, Jun 17, 2009 at 2:34 PM, Fredrik Svensson <
> 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 first solution starts a process for each session, and the second
> only starts a process when a sessions is being used and then save the
> session-id between messages.
> How much is the memory and cpu overhead of each process, do I win
> anything by doing the second solution?
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
More information about the erlang-questions