[erlang-questions] Is using gen_server behaviour appropriate for his usecase?
Fri Nov 30 11:56:53 CET 2012
# Roman Gafiyatullin 2012-11-30:
> The main moral here - use the standard behaviours when spawning your processes.
> The OTP team has solved most of the potential problems for you already :)
The OTP has provided behaviours capturing generic patterns that one encouters
quite often in practice. When the problem at hand fits one such pattern and
nothing in the implementation of the behaviour is playing against desired
operational characteristics that you're working towards, great, standard
behaviour is a good fit.
In other cases though you'll want to create your own generic behaviour.
In other cases you'll want to proc_lib:spawn_link/X your own thing.
In other cases you'll want to erlang:spawn_link/X your own thing.
In some cases you'll want a short-lived one-off process.
In other cases you'll want a hand-written control loop.
Sometimes you want to put these under supervisor, other times you don't.
Repeat the above for non-linking ways of spawning processes.
Erlang provides concurrency primitives as part of the base language, OTP
libraries provide various degrees of elaboration on top of those primitives.
There is a wealth of tools available -- this is not a result OTP designer's
indecisiveness, it is intentional. They are all legitimate tools and each
solves a different problem. Differences between them may be subtle and not
apparent at first, it's good to play around and try different approaches.
Just my 2p, really...
More information about the erlang-questions