如何解释Erlang的监督树?

发布于 2024-07-15 20:03:08 字数 249 浏览 11 评论 0原文

我试图解释监督树。

我最好的尝试是:

好的,你从工厂得到一个巧克力盒,有保修, “每一口都会很好吃。” 然后如果你发现一点点味道很有趣。 你可以把整个盒子扔掉 离开。 因为你从工厂得到的是新的。 这就像 Erlang 中的监督树。 如果一个线程行为不当。 存在所有线程都处于不良状态的风险。 如果是这种情况,主管将丢弃所有线程并重新开始。 就像巧克力盒一样,当你扔掉盒子时,你就是监督者。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

得不到的就毁灭 2024-07-22 20:03:08

您有执行任务的进程 - 工作进程。 可能有许多工人同一种类型 - 都是一样的 - 但也可能有多种类型的工人

您可以通过编写工作进程类型并部署它们来构建应用程序。

监督工作进程主管处理器 - 监督主管进程主管进程(海龟一直向上) ,除了最高的那个是爸爸!)

所有的主管都是一样的。 他们只有两份工作:

  1. 照顾他们的工人(如果他们
    开始崩溃重新启动它们
    那种类型的工人需要的方式
    重新启动)
  2. 如果太多工作人员经常崩溃
    向他们报告
    主管(通过崩溃并让
    他们的主管重新启动他们
    他们需要重新启动的方式)

就是这样。 您可以使用您设计的特殊类型的工作进程构建小型子系统,并使用与其他人相同的几乎无错误、经过全面测试的主管将它们组合成大型多服务器集群以及一些在监督树上运行的标准工作人员,例如将子系统从一台机器移动到另一台机器(这些标准工作人员被编码为 OTP 应用程序和 OTP gen_servers 等行为。

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.

九歌凝 2024-07-22 20:03:08

我的文章我是这样描述的:

在某些方面,Erlang 就像真实的一样
人生:有很多过程
做真正的工作,其中一些是
监督他们。 还有一个
等级制度。 正如我所说,现实生活。
**微笑****

本文的其余部分试图深入了解 Erlang 监督树的概念。

穆埃

In my article 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

帅的被狗咬 2024-07-22 20:03:08

为了响应上面的 Mue,链接已更改。 现在正确的地址是:http://mue.tideland。 biz/软件架构-with-erlangotp-part-7-s

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文