Erlang 在哪里使用以及为什么?

发布于 2024-08-08 17:48:45 字数 152 浏览 2 评论 0 原文

我想知道使用 Erlang 的最常见应用程序/网站/解决方案的列表,成功与否

解释为什么它被用于特定的解决方案而不是其他编程语言也将非常感激。

列出 BAD Erlang 案例研究(Erlang 被滥用的案例)也会很有趣。

I would like to know a list of the most common application/websites/solutions where Erlang is used, successfully or not.

Explaining why it is used into a specific solution instead of others programming languages would be very much appreciated, too.

Listing BAD Erlang case studies (cases in which Erlang is misused) it would be interesting, as well.

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

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

发布评论

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

评论(11

十雾 2024-08-15 17:48:46

来自 Programming Erlang

alt text
(来源:google.com)

许多公司在其生产系统中使用 Erlang:

Amazon使用Erlang实现SimpleDB,作为一部分提供数据库服务
亚马逊弹性计算云(EC2)。

Yahoo! 在其社交书签服务 Delicious 中使用它,该服务拥有超过
500 万用户和 1.5 亿个添加书签的 URL。

Facebook 使用 Erlang 为其聊天服务的后端提供支持,处理超过
1 亿活跃用户。

WhatsApp 使用 Erlang 运行消息传递服务器,每台服务器可容纳多达 200 万连接用户。

T-Mobile 在其 SMS 和身份验证系统中使用 Erlang。

摩托罗拉正在公共安全行业的呼叫处理产品中使用Erlang。

爱立信在其支持节点中使用Erlang,用于GPRS和3G移动网络
全世界。

最流行的开源 Erlang 应用程序包括:

• 3D 细分建模器 Wings 3D,用于建模和纹理多边形
网格。

Ejabberd 系统,提供可扩展消息传递和状态协议
(XMPP) 基于即时消息 (IM) 应用服务器。

CouchDB“无模式”面向文档的数据库,提供可扩展性
跨多核和多服务器集群。

MochiWeb 库为构建轻量级 HTTP 服务器提供支持。
它用于为 MochiBot 和 MochiAds 等服务提供支持,这些服务服务于
每天向数百万观众动态生成内容。

RabbitMQ,AMQP 消息传递协议实现。 AMQP是一个新兴的
高性能企业消息传递标准。

From Programming Erlang:

alt text
(source: google.com)

Many companies are using Erlang in their production systems:

Amazon uses Erlang to implement SimpleDB, providing database services as a part
of the Amazon Elastic Compute Cloud (EC2).

Yahoo! uses it in its social bookmarking service, Delicious, which has more than
5 million users and 150 million bookmarked URLs.

Facebook uses Erlang to power the backend of its chat service, handling more than
100 million active users.

WhatsApp uses Erlang to run messaging servers, achieving up to 2 million connected users per server.

T-Mobile uses Erlang in its SMS and authentication systems.

Motorola is using Erlang in call processing products in the public-safety industry.

Ericsson uses Erlang in its support nodes, used in GPRS and 3G mobile networks
worldwide.

The most popular open source Erlang applications include the following:

• The 3D subdivision modeler Wings 3D, used to model and texture polygon
meshes.

• The Ejabberd system, which provides an Extensible Messaging and Presence Protocol
(XMPP) based instant messaging (IM) application server.

• The CouchDB “schema-less” document-oriented database, providing scalability
across multicore and multiserver clusters.

• The MochiWeb library that provides support for building lightweight HTTP servers.
It is used to power services such as MochiBot and MochiAds, which serve
dynamically generated content to millions of viewers daily.

RabbitMQ, an AMQP messaging protocol implementation. AMQP is an emerging
standard for high-performance enterprise messaging.

十二 2024-08-15 17:48:46

ejabberd 是最知名的 erlang 应用程序之一,也是我学习 erlang 的应用程序。

我认为这是学习 erlang 最有趣的项目之一,因为它确实建立在 erlang 的优势之上。 (然而有些人会争辩说它不是 OTP,但不用担心里面仍然有大量很棒的代码...)

为什么?

XMPP 服务器(如 ejabberd)可以被视为一个高级别的服务器路由器,在最终用户之间路由消息。当然还有其他功能,但这是即时通讯服务器最重要的方面。它必须同时路由许多消息,并处理许多 TCP/IP 连接。

所以我们有两个特性:

  • 处理多个连接
  • 给定消息的某些方面路由消息

这些是 erlang 的亮点示例。

处理多个连接

使用 erlang 构建可扩展的非阻塞 TCP/IP 服务器非常容易。事实上,它就是为了解决这个问题而设计的。
鉴于它可以生成数十万个进程(而不是线程,它是一种无共享方法,设计起来更简单),ejabberd 被设计为一组 erlang 进程(可以分布式在多个服务器上):

  • 客户端连接进程
  • 路由器进程
  • 聊天室进程
  • 服务器到服务器进程

所有这些进程都交换消息。

根据消息的某些方面路由消息

Erlang 的另一个非常可爱的功能是模式匹配
它在整个语言中都有使用。

例如,如下:

access(moderator, _Config)->  rw;
access(participant, _Config)->  rw;
access(visitor, #config{type="public"})->  r;
access(visitor, #config{type="public_rw"})->  rw;
access(_User,_Config)->  none.

这是 access 函数的 5 个不同版本。
Erlang 将根据收到的参数选择最合适的版本。 (Config 是一个 #config 类型的结构,它具有 type 属性)。

这意味着它比链接 if/elseswitch/case 来制定业务规则非常容易且清晰得多。

总结

编写可扩展的服务器,这就是 erlang 的全部意义。一切都经过精心设计,让这一切变得简单。在前面的两个功能中,我添加:

  • 热代码升级
  • mnesia< /code>,分布式关系数据库(包含在基本发行版中)
  • mochiweb,大多数 http erlang 服务器都是基于
  • 二进制支持构建的(解码和编码二进制协议一如既往地简单)
  • 一个拥有优秀开源项目(ejabberdcouchdb 还有webmachineriak 和大量非常容易嵌入的库)

更少的 LOC

也是 Richard Jones 的这篇文章。他将一个应用程序从 C++ 重写为 erlang:erlang 中的行数减少了 75%。

ejabberd is one of the most well know erlang application and the one I learnt erlang with.

I think it's the one of most interesting project for learning erlang because it is really building on erlang's strength. (However some will argue that it's not OTP, but don't worry there's still a trove of great code inside...)

Why ?

An XMPP server (like ejabberd) can be seen as a high level router, routing messages between end users. Of course there are other features, but this is the most important aspect of an instant messaging server. It has to route many messages simultaneously, and handle many a lot of TCP/IP connections.

So we have 2 features:

  • handle many connections
  • route messages given some aspects of the message

These are examples where erlang shines.

handle many connections

It is very easy to build scalable non-blocking TCP/IP servers with erlang. In fact, it was designed to solve this problem.
And given it can spawn hundreds of thousand of processes (and not threads, it's a share-nothing approach, which is simpler to design), ejabberd is designed as a set of erlang processes (which can be distributed over several servers) :

  • client connection process
  • router process
  • chatroom process
  • server to server processes

All of them exchanging messages.

route messages given some aspects of the message

Another very lovable feature of erlang is pattern matching.
It is used throughout the language.

For instance, in the following :

access(moderator, _Config)->  rw;
access(participant, _Config)->  rw;
access(visitor, #config{type="public"})->  r;
access(visitor, #config{type="public_rw"})->  rw;
access(_User,_Config)->  none.

That's 5 different versions of the access function.
Erlang will select the most appropriate version given the arguments received. (Config is a structure of type #config which has a type attribute).

That means it is very easy and much clearer than chaining if/else or switch/case to make business rules.

To wrap up

Writing scalable servers, that's the whole point of erlang. Everything is designed it making this easy. On the two previous features, I'd add :

  • hot code upgrade
  • mnesia, distributed relational database (included in the base distribution)
  • mochiweb, on which most http erlang servers are built on
  • binary support (decoding and encoding binary protocol easy as ever)
  • a great community with great open source projects (ejabberd, couchdb but also webmachine, riak and a slew of library very easy to embed)

Fewer LOCs

There is also this article from Richard Jones. He rewrote an application from C++ to erlang: 75% fewer lines in erlang.

满身野味 2024-08-15 17:48:46

Erlang 最常见的应用程序列表已涵盖(CouchDb、ejabberd、RabbitMQ 等),但我想贡献以下内容。

在这些应用程序中使用它的原因来自于 Erlang 的核心优势:管理应用程序可用性

Erlang 是专门为电信环境而构建的,要求系统至少满足 5x9 的可用性(每年正常运行时间为 99.999%)。这个数字并没有给一年内的停机时间留下太多空间!主要出于这个原因,Erlang 配备了以下功能(非详尽):

  • 水平可扩展性(通过无缝的机器内和机器间通信轻松跨机器边界分配作业的能力)。内置数据库 (Mnesia) 本质上也是分布式的。

  • 垂直可扩展性(在同一台计算机上跨处理资源分配作业的能力):SMP 是本机处理的。

  • 代码热交换:在操作期间实时更新/升级代码的能力

  • 异步:现实世界是异步的,因此 Erlang 的构建就是为了考虑这种基本性质。满足这一要求的一个功能是:Erlang 的“自由”进程(可以并发运行超过 32000 个)。

  • 监督:许多不同的流程监督策略,包括重启策略、阈值等。有助于更轻松地从极端情况/过载中恢复,同时仍然保留问题的痕迹,以便以后进行故障排除、后期处理。尸检分析等。

  • 资源管理:调度策略、资源监控等。请注意,默认进程调度程序以 O(1) 缩放进行操作。

  • 实时调试:随意“登录”实时节点的能力有助于故障排除活动。可以实时进行调试,并完全访问任何进程的运行状态。此外,内置的错误报告工具非常有用(但有时使用起来有些尴尬)。

当然,我可以谈论它的功能根源,但这方面与主要目标(高可用性)有些正交。在我看来,对目标目标做出巨大贡献的功能性质的主要组成部分是:“不分享任何内容”。此特性有助于抑制“副作用”并减少对昂贵的同步机制的需求。

我想所有这些特性都有助于扩展在关键业务应用程序中使用 Erlang 的案例。

Erlang 并不擅长的一件事:处理大数据块。

The list of most common applications for Erlang as been covered (CouchDb, ejabberd, RabbitMQ etc) but I would like to contribute the following.

The reason why it is used in these applications comes from the core strength of Erlang: managing application availability.

Erlang was built from ground up for the telco environment requiring that systems meet at least 5x9's availability (99.999% yearly up-time). This figure doesn't leave much room for downtime during a year! For this reason primarily, Erlang comes loaded with the following features (non-exhaustive):

  • Horizontal scalability (ability to distribute jobs across machine boundaries easily through seamless intra & inter machine communications). The built-in database (Mnesia) is also distributed by nature.

  • Vertical scalability (ability to distribute jobs across processing resources on the same machine): SMP is handled natively.

  • Code Hot-Swapping: the ability to update/upgrade code live during operations

  • Asynchronous: the real world is async so Erlang was built to account for this basic nature. One feature that contributes to this requirement: Erlang's "free" processes (>32000 can run concurrently).

  • Supervision: many different strategies for process supervision with restart strategies, thresholds etc. Helps recover from corner-cases/overloading more easily whilst still maintaining traces of the problems for later trouble-shooting, post-mortem analysis etc.

  • Resource Management: scheduling strategies, resource monitoring etc. Note that the default process scheduler operates with O(1) scaling.

  • Live debugging: the ability to "log" into live nodes at will helps trouble-shooting activities. Debugging can be undertaken live with full access to any process' running state. Also the built-in error reporting tools are very useful (but sometimes somewhat awkward to use).

Of course I could talk about its functional roots but this aspect is somewhat orthogonal to the main goal (high availability). The main component of the functional nature which contributes generously to the target goal is, IMO: "share nothing". This characteristic helps contain "side effects" and reduce the need for costly synchronization mechanisms.

I guess all these characteristics help extending a case for using Erlang in business critical applications.

One thing Erlang isn't really good at: processing big blocks of data.

夜深人未静 2024-08-15 17:48:46

我们使用 Erlang 构建了一个投注交易所(又名预测市场)。由于内置的​​并发性,我们选择了 Erlang,而不是一些更传统的金融语言(C++、Java 等)。市场的功能与电话交换非常相似。我们的 CTO 在 CTO 上发表了关于 Erlang 使用的演讲说话

我们还使用 CouchDB 和 RabbitMQ 作为我们堆栈的一部分。

We built a betting exchange (aka prediction market) using Erlang. We chose Erlang over some of the more traditional financial languages (C++, Java etc) because of the built-in concurrency. Markets function very similarly to telephony exchanges. Our CTO gave a talk on our use of Erlang at CTO talk.

We also use CouchDB and RabbitMQ as part of our stack.

乱世争霸 2024-08-15 17:48:46

Erlang 来自爱立信,并在他们的一些电信系统中使用。

在电信行业之外,CouchDb(面向文档的数据库)可能是迄今为止最著名的 Erlang 应用程序。

为什么是二郎?来自概述(值得全文阅读):

文档、视图、安全性和
复制模型,特殊
目的查询语言,高效
和强大的磁盘布局以及
并发和可靠的性质
Erlang平台都是用心的
集成可靠且
高效的系统。

Erlang comes from Ericsson, and is used within some of their telecoms systems.

Outside telecoms, CouchDb (a document-oriented database) is possibly the best known Erlang application so far.

Why Erlang ? From the overview (worth reading in full):

The document, view, security and
replication models, the special
purpose query language, the efficient
and robust disk layout and the
concurrent and reliable nature of the
Erlang platform are all carefully
integrated for a reliable and
efficient system.

对不⑦ 2024-08-15 17:48:46

我在写报告的过程中发现了这一点: Erlang in Acoustic光线追踪

这是一个研究小组尝试使用 Erlang 进行声射线追踪的经验报告。他们发现,虽然编写程序更容易、错误更少等,但它的扩展性更差,并且执行速度比类似的 C 程序慢 10 倍。因此,它可能不太适合的一个地方是 CPU 密集型场景。

但请注意,写这篇论文的人正处于初次学习 Erlang 的阶段,可能不知道 CPU 密集型 Erlang 的正确开发过程。

I came across this is in the process of writing up a report: Erlang in Acoustic Ray Tracing.

It's an experience report on a research group's attempt to use Erlang for Acoustic Ray Tracing. They found that while it was easier to write the program, less buggy, etc. It scaled worse, and performed 10x slower than a comparable C program. So one spot where it may not be well suited is CPU intensive scenarios.

Do note though, that the people wrote the paper were in the stages of first learning Erlang, and may not have known the proper development procedures for CPU intensive Erlang.

上课铃就是安魂曲 2024-08-15 17:48:46

显然,雅虎使用 Erlang 制作了名为 Harvester 的产品。关于它的文章在这里:http://www.ddj.com/architect/220600332

Apparently, Yahoo used Erlang to make something it calls Harvester. Article about it here: http://www.ddj.com/architect/220600332

萌无敌 2024-08-15 17:48:46

erlang 有什么用?

http://beebole.com/en/blog/erlang/why-erlang/

http://www.aquabu.com /2008/2/15/erlang-pragmatic-studio-day-3-notes

http://www.reddit.com/r/programming/comments/9q0lr/erlang_and_highFrequency_trading/
(jerf 的回答)

重要的是要认识到 Erlang 的 4 个部分:语言本身、VM(BEAM、hipe)标准库(加上 github、CEAN 等上的模块)和开发环境正在稳步更新/扩展/改进。例如,我记得读到当 Wings3d 的作者意识到需要改进时,浮点性能得到了改进(我找不到这方面的来源)。这个人刚刚写了关于它的文章:

http://marian-dan.com/wordpress/?p =324

几年前,Tim Bray 的 Wide Finder 宣传以及所有开始开发 Web 应用程序框架和 HTTP 服务器的人们(至少部分地)改进了正则表达式和二进制文件处理。所有集成 HiPE 和 SMP 的工作、透析器项目、多单元测试和构建库如雨后春笋般涌现,..

所以它的最佳点正在扩大,困难的是官方文档不能很好地跟上,而且邮件列表和 Erlang 博客圈的数量正在快速增长

What is erlang good for?

http://beebole.com/en/blog/erlang/why-erlang/

http://www.aquabu.com/2008/2/15/erlang-pragmatic-studio-day-3-notes

http://www.reddit.com/r/programming/comments/9q0lr/erlang_and_highfrequency_trading/
(jerf's answer)

It's important to realize that Erlang's 4 parts: the language itself, the VMs(BEAM, hipe) standard libs (plus modules on github, CEAN, etc.) and development environment are being steadily updated / expanded/improved. For example, i remember reading that the floating point performance improved when Wings3d's author realized it needed to improve (I can't find a source for this). And this guy just wrote about it:

http://marian-dan.com/wordpress/?p=324

A couple years ago, Tim Bray's Wide Finder publicity and all the folks starting to do web app frameworks and HTTP servers lead (at least in part) to improved regex and binaries handling. And there's all the work integrating HiPE and SMP, the dialyzer project, multiple unit testing and build libs springing up, ..

So its sweet spot is expanding, The difficult thing is that the official docs can't keep up very well, and the mailing list and erlang blogosphere volume are growing quickly

迷途知返 2024-08-15 17:48:46

我们正在使用 Erlang 为我们真正基于浏览器的实时多人游戏提供后端力量 Pixza 。尽管游戏是实时多人游戏,但我们不使用 Flash 或任何其他第三方插件。我们使用纯 JS 和 COMET 技术来代替。而 Erlang 支持 Pixza 的“真正的实时性”。

We are using Erlang to provide the back-end muscle power for our really real-time browser-based multi-player game Pixza. We don't use Flash or any other third-party plugins, though the game is real-time multi-player. We use pure JS and COMET techniques instead. And Erlang supports the "really realtimeliness" of Pixza.

安稳善良 2024-08-15 17:48:46

我在 wooga 工作,这是一家社交游戏公司,我们使用 Erlang 来处理我们的一些游戏后端(基本上是数百万日常用户的 http api)和辅助服务,如 ios 推送通知提供商、支付等。

我认为它在网络方面确实很出色它使得在其中构建和实现简单和复杂的网络服务变得非常简单。分布式、容错性和性能很容易实现,因为 Erlang 已经内置了一些关键成分,并且它们在关键生产基础设施中长期使用。所以它不像“新的髋关节技术0.0.2 alpha”。

我知道其他游戏公司也使用 Erlang。您应该能够在幻灯片共享上找到有关此内容的演示文稿。

I'm working for wooga, a social game company and we use Erlang for some of our game backends (basically http apis for millions of daily users) and auxiliary services like ios push notification provider, payment etc.

I think it really shines in network related tasks and it makes it kind of straight forward to structure and implement simple and complex network services alike in it. Distribution, fault tolerance and performance are easy to achieve because Erlang already has some of the key ingredients built in and they are being used for a long time in critical production infrastructure. So its not like "the new hip technology thing 0.0.2 alpha".

I know that other game companies use Erlang as well. You should be able to find presentations on slideshare about that.

忆梦 2024-08-15 17:48:46

Erlang 的优势在于它是一种没有共享内存的函数式语言。因此,在我看来,Erlang 不适合需要就地内存操作的应用程序。例如图像编辑。

Erlang draws its strength from being a functional language with no shared memory. Hence IMO, Erlang won't be suitable for applications that require in place memory manipulations. Image editing for example.

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