About behavior of OTP's supervisor-worker architecture

Tushar Deshpande tushar.erlang@REDACTED
Mon Sep 13 22:47:01 CEST 2010


I've a question about OTP's supervisor-worker architecture.

I understand that OTP allows us to write fault-tolerant apps.
This is made possible by supervisor-worker architecture.  A
supervisor manages several workers.  If a worker (or a group
of workers) fails then supervisor is able to restart it.  The worker
is restarted and it resumes with the same state that it had
before crash.

Now, let's consider following situation.

A worker process has two possible implementations, P and Q.
Worker P runs under normal conditions.  Worker Q is supposed
to run in case P fails.

If worker P crashes then, supervisor is notified about the crash.
Typically, the supervisor would restart worker P.

But, I would like the supervisor to behave in a different manner.
In case the worker P fails, the supervisor should start the worker Q.
The worker Q should begin its execution with the same state that
P had at the point of crash.

Is it possible to write an OTP application that does this?  If yes,
then do I need to customize the supervisor code.

Best Regards,

Tushar Deshpande

More information about the erlang-questions mailing list