views:

518

answers:

3

Hi, I tried to explain supervision trees.

My best try is:

ok, You get a chocolate box from the factory, with warranty, "Every bit will taste good." Then if you find that one bit taste funny. You can throw the whole box away. Because you get a new from the factory. That is like supervision trees in Erlang. If one thread misbehave. There is a risk that all threads have bad state. If that is the case, the supervisor throw all threads away and start over. Like the chocolate box, you are the supervisor when you throw the box.

+1  A: 

In http://mue.tideland.biz/2009/03/in-some-parts-erlang-is-like-real-life.html I described it this way:

In some parts Erlang is like the real life: there are many processes which do the real work and some which are supervising them. And there's a hierarchy. As I said, real life. **smile**

The rest of the article tries to give a deepe insight into the Erlang supervision tree concept.

mue

Mue
+2  A: 

You have processes that do things - worker processes. There may be many workers of a type - all the same - but there may also be many types of workers.

You build an application by writing types of worker processes and deploying them.

Overseeing the worker processes are supervisor processors - and overseeing the supervisor processes are supervisor processes (turtles all the way up, except for the top one who's the daddy!)

All supervisors are the same. They only have 2 jobs:

  1. look out for their workers (if they start crashing restart them in the way that that type of worker needs to be restarted)
  2. if too many workers crash too often report up the line to their supervisors (by crashing and letting their supervisor restart them in the way that they need to be restarted)

That's it. You build small sub-systems out of special types of worker processes that you have designed and compose them into large, multi-server clusters using the same nearly-bug-free, comprehensively-tested supervisors as everyone else and some standard workers that operate on the supervision tree to do things like move sub-systems from one machine to another (these standard workers are codified in behaviours like OTP applications and OTP gen_servers and stuff.

Gordon Guthrie
A: 

In response to Mue above, the link has changed. The correct address is now: http://mue.tideland.biz/software-architecture-with-erlangotp-part-7-s

Tim Bielawa