One of the things that attracted me to Erlang in the first place is the Actor model; the idea that different processes run concurrently and interact via asynchronous messaging.
I'm just starting to get my teeth into OTP and in particular looking at gen_server. All the examples I've seen - and granted they are tutorial type examples - use handle_call()
rather than handle_cast()
to implement module behaviour.
I find that a little confusing. As far as I can tell, handle_call
is a synchronous operation: the caller is blocked until the callee completes and returns. Which seems to run counter to the async message passing philosophy.
I'm about to start a new OTP application. This seems like a fundamental architectural decision so I want to be sure I understand before embarking.
My questions are:
- In real practice do people tend to use
handle_call
rather thanhandle_cast
? - If so, what's the scalability impact when multiple clients can call the same process/module?