经由 Erlang 开源项目之间的合作“铸就”更好的 key-value 存储系统?
自从 Amazon 的 Dynamo 横空出世,开源的 Erlang 的 Key-Value 存储机制(毕竟有一些区别,因此我并不愿意把这个东西称作数据库)似乎已经成为了一个炙手可热的研究领域。先是有 CouchDB (本站多次介绍,已经被 apache 接纳的开源项目),现在又有了 Kai 。如果算上 Alexander Reinefeld 在 erlang exchange 2008 上展示的项目,很短的时间之内,这一领域已经产生了三个 open source 项目了,可谓进展神速。
说起来,这个新出的 Kai 乃与是我们“一衣带水”的日本同行们的作品。加之此前听说的 Orto,以及零星听说的具有超强并发能力的 tokyocabinet,等。老实说,对于他们在 opensource 领域所表现出来的整体活力,确实有些惊讶。可惜不懂日文,未能对此作进一步的了解。(召唤日语达人整理一下)
话说这几个项目共同关注的是一个相同的问题,然而各自的侧重又略有不同。比如说,Kai 项目实现的乃是(又是) memcache 的访问接口和协议,主要侧重在利用 Erlang 来提升系统在“分布和容错”方面的特性。而 couchDB 则首先关注于实现 key-value 的数据存储本身,在此基础上建立完全不同于 RDBMS 的查询机制,并以优雅的 RESTful 访问接口而著称(Alexander 的项目资料不多,尚不明朗)。应该说是各有特色,而且具有很好的互补性,实在让人很难在这两者之间进行取舍。所以当 couchDB 团队的 Jan Lehnardt 向 Kai 团队的 Takeru Inoue 提出 Collaborate 的建议时,对于广大使用者而言,确实是最为“喜闻乐见”的情形。
或许我们很快就能见到 CouchDB Powered Kai 又或者是 Kai Powered CouchDB,两个项目的特性得到融合,也许,两者之间会形成一种如同 innoDB 之于 mysql 那样的合作关系,谁知道呢?未来充满可能,值得我们期待。开源的 Erlang 就是这么精彩。
上干货 slides on Erlang-Exchange-2008
Erlang-Exchange-2008(别点了,超流量被关啦)刚刚结束,对于我们这些无法亲临现场的“干粉”(干粉==只能干瞪眼的粉丝)而言,等的就是会议结束,各路 slide 纷纷出炉的这一刻。这个场景多少让我想起小时候,看着别人放完炮,一大堆小屁孩就一拥而上,吸溜着鼻涕猛捡那些还没炸完的零碎小鞭炮的岁月。所不同的是,数字时代,每个人都可以捡到“第一手”的干货,不会为了分赃不均而打上一架。不过,任何一个时代,找到干货或者捡到鞭炮的快乐都是相同的,简单而纯粹。下面就是快乐的“干货大放送”(远未集齐,所缺部分希望各位能继续跟帖完善)。
由 Jamaal 同学补充:
在 video.google.com 上搜索 Erlang eXchange 能找到一堆演示视频,虽然没有 PPT/PDF 会略有遗憾,但胜在真人出演,也相当不错。懒得搜索的同学可以点[这里]。
Armstrong on Software: Erlang & SMP,
Joe Armstrong
Introducing Erlang to Motorola: The Journey to Success,
Nicholas Gunder & Torben Hoffman
Erlang- D-Trace,
Garry Bulmer
Erlang & Robotics: The ROSEN Framework at the Eurobot 2008 Competion,
Corrado Santoro
Erlang/OTP Vs Google App Engine, The CEO View,
Gordon Guthrie
Building Web Applications in Erlang,
Xingdong Bian & Michal Slaski
Erlang in Financial Applications,
Dr. Erik Stenman
Erlang and Ajax Web Applications,
Roberto Saccon
Quick Check for Erlang,
John Hughes
Introduction using Faxien & Sinan: Erlang Project Build & Packaging Systems,
Eric Merrit & Martin Logan
Roktalk, Erlang Powered Mobile Conferencing,
Jay Fenton
Wrangerl, The Erlang Refactoring Tool,
Simon Thompson
Enterprise Integration,
Steve Vinoski
Erlang & Tail-F,
Klacke Wikström
Presenting RabbitMQ: An Erlang Based Implementation of AMQP,
Matthias Radestock
EUnit – Lightweight Unit Testing for Erlang,
Richard Carlsson,
ejabberd for web 2.0 development,
Mickael Remond
Load Testing of Web Applications,
Karthik Ramachandra,
Using Jinterface to Bridge Erlang and Java,
Dennis Byrne
Quick Check Tutorial: Using QuickCheck to Test Erlang Programs,
John Hughes & Thomas Arts,
Using Faxien and Sinan, A Hands-on Approach,
Martin Logan & Eric Merrit
Couch DB at 10,000 feet,
Jan Lehnardt
Building a transactional distributed data store with Erlang,
Alexander Reinefeld
Tsung Tutorial,
Mickael Remond,
Erlang Enterprise Integration Panel Discussion,
Garry Bulmer
Good News — Mnesia Unlimited!
我们知道 mnesia 为很多人诟病的一个问题是——它有着诸多让人费解的限制。比如说,在 32 位的系统上,你最多只能存储 4G 的数据。又比如传说中磁盘表让人胆战心惊的修复过程。这些缺陷常常让人在试图推广 erlang 时,总觉得有些底气不足。虽然说,在实用的角度, 4G 其实也够用了,况且还可以分块。但无论怎么说,这种限制毕竟让人不爽。但其实,这些让人尴尬的限制其实并不是 mnesia 代码的问题(冤枉 mnesia 同学了),而是由它底层的存储机制 ets 和 dets 的特性所决定的(好比 mysql 之于 myisam / innodb 的关系)。现在好了,我们可以说,这些让人不快的限制已经可以被抛在脑后了。
Joel Reymont 就是那位在 05 年写出惊到大家的《Writing Low-Pain Massively Scalable Multiplayer Servers》一文的作者。(此文本站亦有中文翻译《轻松实现可伸缩性,容错性,和负载平衡的大规模多人在线系统》,感谢译者“神宗冥浩”)。他这次带给大家的是一个让人惊叹的大礼包——超乎想象的 mnesia 补丁包 mnesiaex 。这个东西解除了加在 mnesia 数据库系统上所有的限制(虽说上面已经提到,实际上 mnesia 代码本身没有什么真正的限制)——你现在可以用 SleepyCat/BerkeleyDB/MySQL/Amazon S3/Tokyo Cabinet/… 甚至是你自己喜欢的某种东西来当作 mnesia 的后端,就像 ets/dets 一样。而访问的接口仍保持不变——继续沿用 mnesia 的接口,一行也不用改。 DIY 这种扩展也变得相当容易,写一个 behavior 就成了。
感谢 Joel Reymont 将这些工作回馈到开源社区。让我们一起祈祷 OTP Team 将这堆 patch 合并到 Erlang 的下一个发布版本中去吧。
顺便 blah 一下:
关于 Erlang
Erlang 就好像是 Ericsson 的私生子,从出生之日起就一直不得宠。在 AXD301 中的耀眼光芒,还是逃脱不了被弃用的命运(Ericsson 又转回去用 C 写交换机了,别让我猜中是因为公司政治)。失败了的 Joe 一伙人被迫离开自组 BlueTail 公司,绝望之中以 Open Source 协议公布了 Erlang 的代码,这个挫折使得它在编程语言的坟场寂寞的躺了多年,但仍然保留着翻盘的火种。默默无闻的完善了多年(加入SMP支持之类),一直不为人所知。直到碰上 CPU 多核变革的机遇,这才重新捡回半条命,并渐渐被人提起。但别忘了,Erlang 直到现在仍然都是由 Ericsson 所拥有(整个的 OTP Team 都是他的员工)和操纵的(你能看到 Erlang 的 souce code 但能访问 Erlang source code 的 SVN 么?)。而比 Sun 的 Java 更加糟糕的是老态龙钟的 Ericsson 从来也没有意识到 Erlang 这个私生子身上所蕴含的潜力。麻烦哪位消息人士请一定转告 Ericsson 的老爷爷们,现在连 Sun 都已经完全开源了 Java ,请抓紧赶上吧,把那些没用的遮遮掩掩全都扔掉。因为对于一个程序设计语言而言,只有 Open Source Community 的程序员们,只有这些人,才是它生命力的真正源泉。在此祈祷 Open Source Erlang 项目朝着更 Open Source Way 的方向前进。
关于 Mnesia
因为工作关系,最近又有机会再来近距离审视 mnesia 这坨神奇的东西。Joe 老头在他的书中说:“关于 Mnesia 的更多内容,恐怕还要再写一本书才能讲得清楚”,现在我(部分地)知道这句话的分量了——我发现自己之前对于 Mnesia 的认识完全错了,而基于新的认识,好多东西都要推翻了重来(害我多做了那么多蹩脚的实现,写了那么多苍白的代码)。我的感觉(现在的)是—— mnesia 根本就不是什么数据库,这只是一个善意的谎言(以它出现的时代来说,太激进,会把人都吓跑了)。实际上,它根本就是一个 Erlang 的 hibernate 。换句话说,这个东西就不应该被拿来当作“数据库”用,而是应该拿来当作“数据层”用。一字之差,谬以千里,熟悉 Java/SSH 编程的同学们相信都能明白我在说什么。实际上,我私下里在怀疑这是 mnesia 最初的设计目的之一,但为了某种原因而故意不去点破这一层。但愿在这个问题上我只是个可耻的阴谋论者。
CouchDB Language Change
续CouchDB 的作者 Damien Katz 炮轰 Erlang 的语法后,现在发布了消息CouchDB Language Change
I’m somewhat sad to say that Erlang will not be used in future releases of CouchDB. We are switching the whole codebase to (…drumroll..) Java.
最大的原因似乎是Erlang开发人员不足
But perhaps the biggest problem with Erlang is the relative lack of Erlang developers. Developers in the US who’ve worked on a successful Erlang project probably number less than 10.
![]()
starling,一个erlang的unicode字符串库
地址在这里:
http://12monkeys.co.uk/starling/
大体的介绍:
An OTP application, with a C pipe driver under the hood.
Based on ICU, the best implementation of Unicode.
Strings stored as binaries ⇒ big memory savings.
Backwards-compatible (mostly) with the standard string module.
[转] InfoQ 对 CORBA Guru Steve Vinoski 的采访
InfoQ 上的[这篇]采访相当有价值。在这个采访中我们能了解到 CORBA 界的大牛 Steve Vinoski 对 CORBA, REST, C++ 的独到看法,很有营养价值。在采访的结尾, Steve 大牛还顺便说了一车 Erlang 的好话。
这一车话用“土磕啦转换器”翻译为大白话,大牛的意思就是“让他老人家在 CORBA 框架中绞尽脑汁试图解决的难题,在 Erlang 中根本就是小菜,浩叹浪费了许多青春云云。”以下内容来自 maillist (有删节):
Ulf Wiger 在推荐这篇访谈时提及:
“In terms of concurrency, if you’re writing middleware I think you owe it to yourself to look at Erlang. The language itself has the primitives, then there are libraries called the Open Telecom Platform that come with it, that build on those primitives to make reliable software almost simple. It’s never simple, but compared to what you have to do, jumping through hoops in other languages, it’s kind of a no-brainer.”
稍后 Steve Vinoski 大牛亲自现身,回复:
… I worked on CORBA starting in 1991 and still use it for certain integration tasks, and in total I helped write 6 or 7 different CORBA ORBs in C++ and Java over the years, including HP ORB Plus and IONA’s Orbix 2000 and its underlying Adaptive Runtime Technology (ART). I worked on other approaches over the years too, including J2EE stuff and WS-* stuff. Some of these systems have been, and in the IONA case still are, heavily used by a variety of large telco, finance, manufacturing, insurance, etc. companies.
Imagine all the issues I’ve encountered over all those years with scalability and performance, portability across operating systems, networking stacks, threads, and different language compilers, plus all the issues with concurrency, reliability, failover, replication, etc. for the distributed services we provided.
A little over year ago I began working for a startup (we’re in stealth mode so I can’t say what we’re working on), and we face many of the same hard distributed system issues. This time, though, I’m armed with Erlang. I started looking at it 2-3 years ago, but couldn’t convince my former company to use it, so I joined my current place instead.
Using Erlang continually makes me both smile and cry at the same time.
I smile because of the overall simplicity it brings to solving all those hard issues I mentioned above, but I also cry knowing how many hours, days, weeks, and months my former colleagues and I spent trying to solve all those really hard issues. We did reasonably well, but it wasn’t easy. If we had had Erlang, I know for certain we could have done so much better.
It all comes back to Robert Virding’s First Rule:
“Any sufficiently complicated concurrent program in another language contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Erlang.”
I now know based on hard-won experience that you could replace “concurrent program” with “distributed system” in Robert’s rule and it would still be just as accurate.
以上即另一位来自“长期战斗在另一条分布式战线”上的大拿对 Erlang 的只言片语,供参考。
另,知悉各位,在一个寒冷而糟糕的漫长春节休假之后,我幸存,并完整无缺的回来了。
[译]Erlang风格的并行
我们常常能在 Erlang 的文档和源码之中看到Ulf Wiger这个名字,他是 Erlang 最初的开发者之一。最近他写了一篇博客《What is Erlang-Style Concurrency?》对于“Erlang风格的并行”发表了自己的看法,粗浅译来,给大家共享。
TSS:Integrating Java and Erlang
知名的 Java 社区 The Server Side 刚刚刊登了Dennis Byrne 的一篇《Integrating Java and Erlang》,Dennis Byrne 来自 ThoughtWorks ,想起上次听 gigix 说起 TW 内部有不少大拿对 Erlang 很感兴趣,看来确实如此。
既然是谈 Java 和 Erlang 的,少不了就会谈到 JInterface :
The world of enterprise software development has a new face: Erlang. Erlang is a functional programming language with native constructs for concurrency and reliability. In this article, Dennis Byrne provides an introduction to the Erlang programming language and Jinterface, an open source component of Ericsson’s Open Telecom Platform. Jinterface gives us the ability to integrate Java and Erlang.
此外,从架构的角度,我也很赞同作者的观点:
Java and Erlang are not mutually exclusive, they complement each other. I personally have learned to embrace both because very few complex business problems can be modeled exclusively from an object oriented or functional paradigm. The solutions to these problems can be sequential or concurrent. Jinterface can cleanly divide (and conquer) a system into parts suitable for Java and parts suitable for Erlang.
JInterface 的价值就在于,它能将系统 COP 的部分(Erlang)和 OOP 的部分(Java)分离开来,大家各自解决自己擅长的问题,并且彼此协作形成完整的系统。
好了,好文已经转完,下面开始 blah
[译]What’s all this fuss about Erlang
作者:Joe Armstrong
原文:What’s all this fuss about Erlang
译者:朱照远(Joshua Zhu) 许式伟(XuShiWei)
朱照远和许式伟同学我们都很熟悉,这一次,他们给大家带来了《三言两语话Erlang》(个人感觉,这个中文译名抓住了原文的精髓啊),这是 Joe Armstong 在 pragprog 上的文章。在这一篇中,对于那些初次接触 Erlang 的读者, Joe “三言两语”就把 Erlang 这个 Fuss 给说了个明明白白清清楚楚。
实际上,当我们头一次从“并发、容错、分布、负载”这些“链接”点到 Erlang 的某一个网页里时,从来也没有想过这个语言竟然可以如此的简单。对我来说,在半信半疑之间做完 Getting Started 教程时,我还在想:“怎么就没了?这么简单,怎么可能?”。是啊,我们从来都是被这些大词给吓大的嘛,专门用来解决那些难题的语言竟然会这么简单,这个现实确实让人难以接受。
而 Joe 的这篇文章就是专门来讲“这是怎么成为可能的”——我们从来就没有想过“编程思想”有局限的可能。
让我们对 朱照远(Joshua Zhu) 和 许式伟(XuShiWei) 向 erlang 中文社区作出的贡献表示感谢!
老规矩,在线版和 PDF 版一起放送。
Introducing… CouchDB!
pi1ot 同学提了一个问题:
javaeye上看到的“用Erlang开发的文档数据库系统CouchDB”是个什么东西,啥叫文档数据库啊
这是一个好问题,因为我也老见到这个名字,但总不知其所以然,因此,特地作了一下 research ,将我了解到的,与诸君共享。


Recent Comments