Gen_server and multiple processes

Francesco Cesarini <>
Fri Dec 20 10:04:40 CET 2002

>>Yes. You have a message server that receives all messages and spawns a 
>>new server (Let us call it a message handler)
>Just to check, you mean to actually spawn a new OTP gen_server?  Is this
>not slow since it has quite a bit of overhead.
>The idea we had was to have one gen_server that spawns its own worker
>threads in the handle_call.
I would first try with a dynamic child in a gen_server. Yes, you do have 
overheads, but at the same time, you have supervision, control, and 
uniformity. I think the overhead should be neglectable. If it is still 
slow, then go ahead and start using special processes. They are however 
rare, and the extra performance has to my knowledge only been needed in 
very few cases.

>>No. Implement your translator as a function which is called by the 
>>message handler. There is no need for extra message passing or 
>The idea we had was that by putting the translators (there is more than
>one flavor of translator) into OTP servers we would more easily be able
>to distribute them over the number of processors we have. 
>doing some load balancing on the way.  This seemed to be the easiest way
>to get that going quickly.
Have a different module for every different translator, and use pattern 
matching to pick the right one. Then, the only thing you have to 
distribute among the processors is the message handler. That is easily 
achieved with a round robin scheduler.


More information about the erlang-questions mailing list