随笔-11  评论-10  文章-8  trackbacks-0
多谢 erlang-china 的提醒,今天从 mailing list 中翻出了关于RPC的讨论,深有感触 -- 牛人就是牛人!!!

关于 RPC is bad 的主要论点如下:
The fundamental problem of RPC, which is trying to make remote calls look local, is based on essentially trying to ignore the problems covered by the fallacies or trying to pretend they don't even exist

严重同意,理由如下:

Network partitions are real, timeouts are real, remote host and service
crashes are real, the need for piecemeal system upgrade and handling
version differences between systems is real, etc. The distributed
systems programmer
*must* deal with these and other issues because
they affect different applications very differently.


这一点非常赞同,也深有同感。在做FileServer的时候所有的节点都是通过RMI进行通讯,最初使用RMI的目的就是
简化网络部分的开发,对于一般的开发人员无须理解RMI,动态代理,只需要像使用本地方法一样就可以访问远程
节点。这种方案确实很好的隐藏了网络细节,使网络对开发人员完全透明,但有个问题始终无法很好的处理:异常。
网络错误是随时都有可能发生的,对于不同的错误需要根据环境和需要做具体的处理,比如,多试几次,尝试下一个
节点,对于无法处理的还可以直接抛出。而这种策略的选择和使用必须由应用逻辑层完成,可是应用层假设是不知道
网络存在的,它甚至无法知道自己调用的方法中哪个是远程调用,哪个是本地调用。这种矛盾从根本上说明了网络的
复杂性和多样性是开发分布式应用的程序员必须面对的,是逃不掉的,要直面这惨淡的人生T_T

下面阐述了使用类型系统的缺陷:
Such systems also have problems with impedance mismatch between the
IDL and whatever languages you're translating it to. If the IDL is
minimal so that it can be used with a wide variety of programming
languages, it means advanced features of well-stocked languages like
Java and C++ can't be used. OTOH if you make the IDL more powerful so
that it's closer to such languages, then translating it to C or other
more basic languages becomes quite difficult.
On top of all that, no matter how you design the IDL type system, all
the types won't -- indeed, can't -- map cleanly into every desired
programming language.

类型系统一直都在进化,从弱到强到动态,你相信会有一种类型系统可以和所有
的其他语言进行完美的映射吗?如果真存在,类型系统的进化就毫无意义了。定义
一个新的语言,然后映射到其他语言,最后号称“我是跨语言跨平台的!”,这种
解决问题的方式根本就是有问题的。WSDL使用XML描述,有着更好的可扩展性,只是
酒瓶换新酒,根烂了,再换也没用。

Ultimately, RPC is a leaky abstraction. It can't hide what it tries to
hide, and because of that, it can easily make the overall problem more
difficult to deal with by adding a lot of accidental complexity.

下面对为什么 message queuing system 适合分布式系统做了很好的总结:
Message queuing systems work well because (in no particular
order):

* they don't pretend to be programming language procedure or method
calls, so they avoid the associated impedance mismatch problems
* they don't try to hide distributed systems issues
* coupling is low -- drop a message into a queue here, pick up a
message from a queue there
* queues can be persistent, or more generally, delivery guarantees can
be varied as needed
* asynchrony
* payloads need not conform to some made-up IDL type system
* getting two different messaging systems to interoperate is easier
than getting two different RPC or distributed object systems to
interoperate
这和我在自己的硕士论文中的观点有些相似:完全使用消息机制进行构件间的通讯。构件可以
是分布式的或在容器中的,基于消息的通讯都是完全适用的。对于网络应用同样如此。对于流行
的网络协议,HTTP,FTP,LDAP 等等都是消息式的,完全经历了时间的考验。

posted on 2008-05-28 00:32 JBahamut 阅读(461) 评论(1)  编辑  收藏

评论:
# re: 读 Erlang mailing list 有感 2008-06-24 01:55 | mier
你java好强大  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: