什么是Erlang的并发模式呢? [英] What is Erlang's concurrency model actually?

查看:128
本文介绍了什么是Erlang的并发模式呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近正在阅读一篇文章为什么事件不好。本文是对基于事件和线程的高并发服务器的比较研究,最后得出结论,指出线程比那种情况下的事件更好。

I was reading a paper recently Why Events are Bad. The paper is a comparative study of Event based and thread based highly concurrent servers and finally concludes stating that Threads are better than events in that scenario.

我发现我不是能够分类什么样的并发模型erlang暴露。 Erlang提供轻量级进程,但这些进程大部分时间都被暂停,直到它收到某种事件/消息。

I find that I am not able to classify what sort of concurrency model erlang exposes. Erlang provides Light Weight Processes, but those processes are suspended most of the time until it has received some event/message of some sort.

/ Arun

推荐答案

Erlang并发模型基于以下内容:

The Erlang concurrency model is based on the following premises:


  • 轻量级并发。您应该能够有效地为应用程序创建尽可能多的进程,并且在必要时可以有效地创建和删除它们。这意味着流程很轻,而且不需要一个流程池来节省时间。

  • Lightweight concurrency. You should be able to efficiently create as many processes as you need for your application and you should be able efficiently to create and delete them when necessary. This means that processes are light and small and there is no need to have a process pool to save time.

异步通信。所有流程通信都是通过异步消息传递,就是没有别的,nada。

Asynchronous communication. All process communication is through asynchronous message passing, that's it, there is nothing else, nada.

错误处理。与轻量级并发和异步消息相同的方式是构建并发系统的基础,错误处理是构建强大系统的基础。这些原始图形与并发性相互作用,是Erlang并发模型的一部分。

Error handling. The same way as as lightweight concurrency and asynchronous messages are fundamental to building concurrent systems error handling is fundamental to building robust systems. The primitives for this interact with concurrency and are part of the Erlang concurrency model.

进程隔离。进程间没有共享状态,唯一的通信方式是通过消息传递。这是能够构建强大系统的基础,因为它允许进程崩溃而不会为其他进程造成破坏。当然,他们可能会收到一个进程通过错误处理机制崩溃的信息,但是崩溃的将不会在其他进程中创建不一致的状态。这是一个推论,没有全球数据。

Process isolation. There is no shared state at all between processes, the only way to communicate is through message passing. This is fundamental to being able to build robust systems as it allows processes to crash without ruining it for other processes. Of course they may receive information that a process has crashed through the error handling mechanism but a crashed will never create inconsistent state in other processes. A corollary to this is that there is no global data.

这些是Erlang并发模型的基础。你可能经常看到他们以不同的方式表达,但基本上是一样的。 Erlang还有一个不可变数据,这是一个大的WIN,但这并不是并发模型的一部分,消息传递和进程隔离就足够了。在某些圈子里,这可能被认为是一个异端的观点。

These are the fundamental premises to Erlang's concurrency model. You may often see them expressed in different ways but they are basically the same. Erlang also has immutable data which is a BIG WIN but this is not really part of the concurrency model, message passing and process isolation are enough. In some circles this may be considered a heretical viewpoint.

正如你所看到的,Actors只是模型的一部分。错误处理是根本的,但往往被忽视。忽略它意味着你错过了一点。

As you can see Actors are only part of the model. Error handling is fundamental but often overlooked. Overlooking it means you have missed part of the point.

N.B。 Erlang进程是适当的进程/线程,因为它们具有自己的生命,并不仅仅是事件驱动协同程序的一种形式。一个进程可以高兴地开展业务,改变其内部状态,而不受外部事件的驱动。

N.B. Erlang processes are proper processes/threads in that they have a life of their own and are not just a form of event driven coroutines. A process can happily go about its business and change its internal state without being driven by external events.

这篇关于什么是Erlang的并发模式呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆