English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

编程分布式 Erlang

Distributed programs are those designed to run on computer networks and can only coordinate their activities through message passing.

There are many reasons why we might need to write distributed applications. Here are some of them.

  • Performance - By running different parts of the program in parallel on different machines, the program can run faster.

  • 可靠性 − 我们可以通过将系统构造为在多台机器上运行来制造容错系统。如果一台机器发生故障,我们可以在另一台机器上继续。

  • 可扩展性 − 在扩展应用程序时,迟早将耗尽甚至是功能最强大的计算机的功能。在此阶段,我们必须添加更多计算机以增加容量。添加新计算机应该是简单的操作,不需要对应用程序体系结构进行大的更改。

分布式Erlang中的中心概念是节点。节点是独立的。

Erlang 系统包含一个完整的虚拟机,它有自己的地址空间和一组进程。

让我们来看看分布式编程中使用的不同方法

序号方法与说明
1

spawn

这用于创建新进程并对其进行初始化

2

node

这用于确定进程需要在其上运行的节点的值

3

spawn 节点

这用于在节点上创建新进程

4

is_alive

如果本地节点处于活动状态并且可以是分布式系统的一部分,则返回true

5

spawnlink

这用于在节点上创建新的进程链接