Both functions start new gen_server
instances as children of the calling process, but they differ in that the gen_server:start_link/3,4
atomically starts a gen_server
child and links it to its parent process. Linking means that if the child dies, the parent will by default also die. Supervisors are parent processes that use links to take specific actions when their child processes exit abnormally, typically restarting them.
Other than the linking involved in the gen_server:start_link
case, there are no multi-process aspects involved in these calls. Regardless of whether you use gen_server:start
or gen_server:start_link
to start a new gen_server
, the new process has a single message queue, and it receives and processes those messages one at a time. There is nothing about gen_server:start_link
that causes the new gen_server
process to behave or perform differently than it would if started with gen_server:start
.
gen_server
concurrently, their messages are queued in thegen_server
message queue, and thegen_server
processes those messages one at a time. – Frieder