Let it crash philosophy for distributed systems
This past weekend I read Joe Armstrong’s paper on the history of Erlang. Now, HOPL papers in general are like candy for me, and this one did not disappoint. There’s more in this paper that I can cover in one post, so today I’m going to concentrate on one particular feature of Erlang highlighted by Armstrong.
Although Erlang is designed to encourage/facilitate a massively parallel programming style, its error handling may be even more noteworthy. Like everything else in Erlang, its error handling is designed to be distributed, and for good reason:
Error handling in Erlang is very different from error handling in conventional programming languages. The key observation here is to note that the error-handling mechanisms were designed for building fault-tolerant systems, and not merely for protecting from program exceptions. You cannot build a fault-tolerant system if you only have one computer. The minimal configuration for a fault tolerant system has two computers. These must be configured so that both observe each other. If one of the computers crashes, then the other computer must take over whatever the first computer was doing.
This means that the model for error handling is based on the idea of two computers that observe each other.
Erlang is famous for its features which help programmers to produce stable systems in the real world. Its shared nothing architecture and ability to hot-swap code are well-known. But these features are available in other systems. The "links" feature, on the other hand, seems to be unique. When you create a process in Erlang, you can link it to another process; this link essentially means, "If that process crashes, I’d like to crash, also; and if I crash, that process should die, too." Here is Armstrong’s description:
Links in Erlang are provided to control error propagation paths for errors between processes. An Erlang process will die if it evaluates illegal code, so, for example, if a process tries to divide by zero it will die. The basic model of error handling is to assume that some other process in the system will observe the death of the process and take appropriate corrective actions. But which process in the system should do this? If there are several thousand processes in the system then how do we know which process to inform when an error occurs? The answer is the linked process. If some process A evaluates the primitive link(B) then it becomes linked to A . If A dies then B is informed. If B dies then A is informed.
Using links, we can create sets of processes that are linked together. If these are normal processes, they will die immediately if they are linked to a process that dies with an error. The idea here is to create sets of processes such that if any process in the set dies, then they will all die. This mechanism provides the invariant that either all the processes in the set are alive or none of them are. This is very useful for programming error-recovery strategies in complex situations. As far as I know, no other programming language has anything remotely like this.
In addition to simply killing the linked process, the link can also function as a kind of signal to a system process that a group of processes have died, so that appropriate action can be taken, such as restarting a process group.
Like Armstrong, I cannot think of another system that works quite this way. The closest analogy I can think of is a distributed transaction. But distributed transactions have quite a bit more overhead, because they’re all about providing serializable access to shared data, which Erlang just doesn’t allow.
Armstrong says that the idea of links was inspired by the ‘C wire’ in early telephone exchanges:
The C wire went back to the exchange and through all the electromechanical relays involved in setting up a call. If anything went wrong, or if either partner terminated the call, then the C wire was grounded. Grounding the C wire caused a knock-on effect in the exchange that freed all resources connected to the C line.
Armstrong says that the links feature encourages a worker/supervisor style of programming which is "not possible in a single threaded language."
Let it crash philosophy for distributed systems的更多相关文章
- Let it crash philosophy part II
Designing fault tolerant systems is extremely difficult. You can try to anticipate and reason about ...
- Distributed systems theory for the distributed systems engineer
Gwen Shapira, SA superstar and now full-time engineer at Cloudera, asked a question on Twitter that ...
- 可扩展的Web系统和分布式系统(Scalable Web Architecture and Distributed Systems)
Open source software has become a fundamental building block for some of the biggest websites. And a ...
- Scalable Web Architecture and Distributed Systems
转自:http://aosabook.org/en/distsys.html Scalable Web Architecture and Distributed Systems Kate Matsud ...
- Scalable, Distributed Systems Using Akka, Spring Boot, DDD, and Java--转
原文地址:https://dzone.com/articles/scalable-distributed-systems-using-akka-spring-boot-ddd-and-java Whe ...
- [翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed Systems"
[翻译] TensorFlow 分布式之论文篇 "TensorFlow : Large-Scale Machine Learning on Heterogeneous Distributed ...
- [分布式系统学习]阅读笔记 Distributed systems for fun and profit 抽象 之二
本文是阅读 http://book.mixu.net/distsys/abstractions.html 的笔记. 第二章的题目是"Up and down the level of abst ...
- [分布式系统学习]阅读笔记 Distributed systems for fun and profit 之一 基本概念
因为工作的原因,最近打算看一些分布式学习的资料.其中这个http://book.mixu.net/distsys/就是一篇非常适合分布式入门的介绍. 这个短小的材料有下面5个小的章节,图文并茂,也没有 ...
- Fault-Tolerance, Fast and Slow: Exploiting Failure Asynchrony in Distributed Systems
本文(OSDI 18')主要介绍一种新的副本复制协议:SAUCR(场景可感知的更新与故障恢复).它是一种混合的协议: 在一定场景(正常情况)下:副本复制的数据缓存在内存中. 故障发生时(多个节点挂掉, ...
随机推荐
- UCI一位搞theory的教授列的一些数学方面的比较趣味性的网页
http://www.ics.uci.edu/~eppstein/recmath.html 据说是recreational的,没具体看,先收藏下来.
- win8 机器硬盘异响
win8系统安装在ssd上,挂了一块希捷2T的机器硬盘做数据存储用,经常发生异响.类似通电断电的声音.因为硬盘的APM节能使磁头归位造成的声音. 使用CrystalDiskInfo软件禁用APM,异响 ...
- mongodb查询速度慢是什么原因?
mongodb查询速度慢是什么原因? 通过mongodb客户端samus代码研究解决问题 最近有项目需要用到mongodb,于是在网上下载了mongodb的源码,根据示例写了测试代码, ...
- Spring boot 、mybatis、swagger、c3p0、redis 和mongodb 整合
文件路径: 添加依赖: <?xml version="1.0" encoding="UTF-8"?> <project ...
- php 共享内存学习(shmop函数)
问题:希望可以在进程间共享变量,为共享数据提供快速访问 解决方案:除了可以使用APC模块,还可以用shmop或System V共享内存 //创建键 //将一个可访问的文件路径名转换为一个可供 shmo ...
- Gcc And MakeFile Level1
简单介绍gcc And make 的使用 基本编译 gcc a.c b.c -o exeName 分步编译 gcc -c a.c -o a.o gcc a.o b.c -o main.o 使用Make ...
- iis 搭建ftp
1.打开iis,添加FTP站点 2.在电脑上建立的FTP服务器别的电脑不能访问 关闭防火墙即可访问防火墙 程序员的基础教程:菜鸟程序员
- 谈谈WhatsApp一年设计经历和收获
以下内容由Mockplus团队翻译整理,仅供学习交流,Mockplus是更快更简单的原型设计工具. 关于WhatApp和Facebook如何实现规模设计的思考 我已经在Facebook担任产品经理 ...
- oracle存储过程和游标参考
oracle open cursor forhttp://www.itpub.net/thread-1874683-1-1.html
- centos7安装kubernetes 1.1
原文地址:http://foxhound.blog.51cto.com/1167932/1717105 前提:centos7 已经update yum update -y 一.创建yum源 maste ...