# Erlang/OTP

**Erlang/OTP** 是一套完整的并发编程开发环境，它将 [Erlang](https://www.edgepedia.org/zh/erlang-programming-language) 编程语言、其运行时系统，以及一套名为 OTP（Open Telecom Platform，开放电信平台）的库与设计原则结合在一起，用于构建健壮、容错的分布式应用。<sup>[1](https://github.com/erlang/otp)</sup><sup> • </sup><sup>[2](https://www.erlang.org/docs/26/)</sup> Erlang 最初由爱立信计算机科学实验室开发，爱立信内部的 Erlang/OTP 部门至今仍是主要的开发者和维护者。<sup>[3](https://www.erlang.org/about)</sup>

| 关键事实 | 详情 |
|---|---|
| 组成部分 | Erlang 语言与运行时系统，外加 OTP：一套 Erlang 库，由运行时系统、主要用 Erlang 编写的现成组件，以及面向 Erlang 程序的设计原则组成<sup>[1](https://github.com/erlang/otp)</sup> |
| 起源 | 由 Bjarne Däcker 领导的爱立信计算机科学实验室创造；后来爱立信内部另设 OTP 部门，以将该实现商业化并使其稳定<sup>[4](https://www.erlang.org/news/96)</sup> |
| 开源 | 1998 年 12 月 8 日以开源形式发布<sup>[4](https://www.erlang.org/news/96)</sup> |
| 许可证 | 自 OTP 18.0 起采用 Apache License 2.0；更早的版本使用 Erlang Public License（EPL），它是 Mozilla Public License 的衍生许可证<sup>[5](https://www.erlang.org/downloads)</sup> |
| 最新版本 | 29.1.1<sup>[5](https://www.erlang.org/downloads)</sup> |
| 设计目标 | 满足高可用性要求的大规模可扩展软实时系统<sup>[1](https://github.com/erlang/otp)</sup> |
| 工业应用 | 在爱立信 AXD301 ATM 交换机等产品中久经考验；被用作 RabbitMQ 和 WhatsApp 消息后端的基石<sup>[3](https://www.erlang.org/about)</sup><sup> • </sup><sup>[6](https://www.rabbitmq.com/resources/erlang-exchange-talk-final/ex)</sup><sup> • </sup><sup>[7](https://blog.whatsapp.com/on-e-millio-n)</sup> |

## OTP 提供什么

OTP 不只是一组库。它的设计原则规定了如何以进程、模块和目录来组织 Erlang 代码，而《OTP 设计原则》指南描述了如何构建 Erlang/OTP 应用。<sup>[8](https://www.erlang.org/docs/27/system/design_principles.html)</sup>《系统原则》指南描述了如何构建 Erlang/OTP 系统，整套系统文档则涵盖在 Unix 和 Windows 上的安装、入门、关于记录、匿名函数、列表推导和位语法的编程示例、一份效率指南、一份互操作教程（主要是 Erlang 与 C），以及一份嵌入式系统用户指南。<sup>[9](https://www.erlang.org/doc/system/)</sup>

少数 OTP 应用，例如 C 接口 erl_interface，是用 Erlang 之外的语言实现的，不包含任何 Erlang 模块。<sup>[2](https://www.erlang.org/docs/26/)</sup> 一个与 Erl_Interface 类似、面向 Java 的库名为 jinterface，在 Erlang/OTP R6B 中加入。<sup>[10](https://github.com/erlang/otp/blob/master/system/doc/tutorial/overview.md)</sup>

## 并发与运行时系统

与操作系统线程和进程相比，Erlang 进程是轻量级的。在 v5.6 时代的一次测量中，在不支持 HiPE 的非 SMP 模拟器里，一个新生成的 Erlang 进程占用 309 个字的存储，其中 233 个字是包含栈的堆区；垃圾回收器会按需扩大堆。<sup>[11](https://www.erlang.org/docs/17/efficiency_guide/processes.html)</sup> 233 个字的默认初始堆大小是刻意保守设定的，以支持拥有数十万甚至数百万个进程的系统。<sup>[11](https://www.erlang.org/docs/17/efficiency_guide/processes.html)</sup>

**内存管理**发生在单个进程的层面：每个 Erlang 进程都有自己的分代回收器，用 Cheney 算法在两个半空间之间复制存活数据，另有一个用于大对象的全局堆作为补充。<sup>[12](https://beta.erlang.org/doc/apps/erts/garbagecollection.html)</sup> 每当 Erlang 进程交换消息时，消息中的所有内容都会被复制——唯一的例外是 refc 二进制，前提是两个进程位于同一个 Erlang 节点上。<sup>[11](https://www.erlang.org/docs/17/efficiency_guide/processes.html)</sup> 自 Erlang/OTP 19.0 起，接收进程的 `message_queue_data` 标志控制着传入消息数据的分配方式以及垃圾回收器对它的处理方式；在 19.0 之前，其行为始终接近 `on_heap` 选项。<sup>[12](https://beta.erlang.org/doc/apps/erts/garbagecollection.html)</sup>

**分布式支持**是内建的：不同节点上进程之间的消息传递和错误处理是透明的，当消息被发送给另一个 Erlang 节点上的进程时，它会先被编码为 Erlang 外部格式，然后通过 TCP/IP 套接字发送。<sup>[10](https://github.com/erlang/otp/blob/master/system/doc/tutorial/overview.md)</sup><sup> • </sup><sup>[11](https://www.erlang.org/docs/17/efficiency_guide/processes.html)</sup>

## 实践中的容错

OTP 的监督模型建立在进程链接和监督层级之上，是项目选择该平台的一个核心原因。实现 AMQP 商业消息标准的 RabbitMQ 团队，将 Erlang/OTP 用于构建高可靠系统的设计列为其选择的主要原因之一；他们于 2007 年 2 月发布的第一个公开版本约有 5,000 行 Erlang 代码。<sup>[6](https://www.rabbitmq.com/resources/erlang-exchange-talk-final/ex)</sup> RabbitMQ 的开发者指出，从 AMQP 的逻辑架构到基于 Erlang 的设计之间的映射十分自然，由此产生了一个小巧、易读的代码库，其中 AMQP 的特性与代码片段直接对应。<sup>[13](https://www.rabbitmq.com/resources/google-tech-talk-final/google)</sup>

WhatsApp 报告称，2011 年 9 月在单台机器上达到了 1,016,313 个已建立的 TCP 会话，并将后端技术简单地描述为 FreeBSD + Erlang。<sup>[7](https://blog.whatsapp.com/on-e-millio-n)</sup>

学术评估在特定场景中支持了这些可靠性主张。赫瑞瓦特大学一项在 Beowulf 集群上针对调度呼叫控制器（DCC）应用的研究发现，Erlang 实现满足了该应用的资源回收和软实时要求，在 4 个处理器上以 1000% 负载实现了 101% 的吞吐量，并且可以通过增加节点进行动态升级而不中断服务；Erlang 版 DCC 的规模不到同类 C++/CORBA 实现的四分之一。<sup>[14](https://researchportal.hw.ac.uk/en/publications/are-high-level-languages-suitable-for-robust-telecoms-software/)</sup>

## 历史与发布实践

Erlang 背后的工作源于 1981 年爱立信启动的一项研究计划，旨在寻找更好的电信应用编程方式，其成果包括 Erlang 语言、一套设计方法学，以及一套用于构建健壮系统、名为 OTP 的库；Joe Armstrong 的博士论文《在软件错误存在的情况下构建可靠的分布式系统》（*Making reliable distributed systems in the presence of software errors*）描述了这些起源。<sup>[15](https://dcatkth.github.io/thesis/joe_thesis.pdf)</sup> 在开源之前，Erlang 和 OTP 已被用于开发爱立信的若干商业电信产品，开源版本经过了充分测试且稳定可靠。<sup>[4](https://www.erlang.org/news/96)</sup> Erlang/OTP 负责人、最初的工作人员之一 Kenneth Lundin 将开源描述为对爱立信和开源社区都有利的决定。<sup>[4](https://www.erlang.org/news/96)</sup>

**发布节奏**是规律的。主要版本每年 5 月发布：OTP 26.0 于 2023 年 5 月 16 日，OTP 27.0 于 2024 年 5 月 15 日，OTP 28.0 于 2025 年 5 月 21 日，OTP 29.0 于 2026 年 5 月 13 日，每个版本之前都有若干候选版本，之后是主要包含缺陷修复的维护补丁包。<sup>[16](https://www.erlang.org/news)</sup> 版本树将 Erlang/OTP 17.0 以来的每个版本都纳入《系统原则指南》中记载的版本方案。<sup>[5](https://www.erlang.org/downloads)</sup>

## 可扩展性与性能

研究也描绘了该平台的极限。一项关于 Erlang 分布式参与者平台的研究确立了 Erlang 系统的可扩展性极限，并报告了架构上的改进；SD Erlang 是一种分区变体，在超过 80 台主机时减少了网络流量并提升了 Orbit 和 ACO 基准测试的性能，而测量表明，除非恢复数据本身被分区，否则维护全局恢复数据会极大地限制可扩展性。<sup>[17](https://arxiv.org/abs/1704.07234)</sup>

在性能分析方面，Erlang/OTP 附带若干工具：cprof 是最轻量的，按函数提供所有进程的执行计数；recon 则是一组性能分析与调试工具。<sup>[18](https://www2.erlang.org/documentation/doc-9.2/doc/efficiency_guide/profiling.html)</sup>

## Erlang 之外的采用

OTP 的概念已被带入其他生态系统。Elixir 运行在同一个 BEAM 虚拟机上，并高度依赖 OTP，因此要解读用它构建的系统的结果，理解 Erlang 环境至关重要。<sup>[19](https://www.mdpi.com/2073-431X/15/7/439)</sup> RabbitMQ 的维护者同样选择用 Erlang 在 OTP 之上构建他们的 AMQP 层，而不是创建新的消息基础设施，从而将该平台的健壮性和可扩展性与 AMQP 的消息模型结合起来。<sup>[20](https://www.rabbitmq.com/resources/RabbitMQ_PressRelease_080207.pdf)</sup>

## References

1. [erlang/otp repository README, GitHub](https://github.com/erlang/otp)
2. [Erlang/OTP 26.2.5.21 documentation welcome page](https://www.erlang.org/docs/26/)
3. [About, Erlang/OTP](https://www.erlang.org/about)
4. [Erlang/OTP - 17 Years of Open Source, Erlang/OTP news](https://www.erlang.org/news/96)
5. [Downloads, Erlang/OTP](https://www.erlang.org/downloads)
6. [RabbitMQ: An Implementation of AMQP in Erlang/OTP, Erlang Exchange talk](https://www.rabbitmq.com/resources/erlang-exchange-talk-final/ex)
7. [ONE MILLION!, WhatsApp Blog, September 23, 2011](https://blog.whatsapp.com/on-e-millio-n)
8. [OTP Design Principles Overview, Erlang System Documentation](https://www.erlang.org/docs/27/system/design_principles.html)
9. [Erlang/OTP System Documentation](https://www.erlang.org/doc/system/)
10. [Interoperability Tutorial overview, erlang/otp on GitHub](https://github.com/erlang/otp/blob/master/system/doc/tutorial/overview.md)
11. [Processes, Efficiency Guide, Erlang/OTP 17 documentation](https://www.erlang.org/docs/17/efficiency_guide/processes.html)
12. [Erlang Garbage Collector, ERTS User's Guide, OTP 29.1.1](https://beta.erlang.org/doc/apps/erts/garbagecollection.html)
13. [RabbitMQ server design, Google tech talk](https://www.rabbitmq.com/resources/google-tech-talk-final/google)
14. [Are high-level languages suitable for robust telecoms software?, Heriot-Watt Research Portal](https://researchportal.hw.ac.uk/en/publications/are-high-level-languages-suitable-for-robust-telecoms-software/)
15. [Joe Armstrong, Making reliable distributed systems in the presence of software errors, PhD thesis](https://dcatkth.github.io/thesis/joe_thesis.pdf)
16. [News, Erlang/OTP](https://www.erlang.org/news)
17. [Scaling Reliably: Improving the Scalability of the Erlang Distributed Actor Platform, arXiv:1704.07234](https://arxiv.org/abs/1704.07234)
18. [Profiling, Efficiency Guide, Erlang/OTP 9.2 documentation](https://www2.erlang.org/documentation/doc-9.2/doc/efficiency_guide/profiling.html)
19. [Benchmarking Fault-Tolerance Characteristics of Actor-Based Runtimes, MDPI Computers](https://www.mdpi.com/2073-431X/15/7/439)
20. [RabbitMQ press release, February 2008](https://www.rabbitmq.com/resources/RabbitMQ_PressRelease_080207.pdf)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/erlang-otp

English original: https://www.edgepedia.org/erlang-otp
