简体   繁体   English

分布式服务如何优于分布式对象?

[英]How are distributed services better than distributed objects?

I am not interested in the technology eg CORBA vs Web Services, I am interested in principles. 我对技术不感兴趣,例如CORBA vs Web Services,我对原则很感兴趣。 When we are doing OOP, why should we have something so procedural at higher level? 当我们在进行OOP时,我们为什么要在更高层次上拥有如此程序化的东西? Is not it the same as with OOP and relational databases? 是不是与OOP和关系数据库相同? Often services are supported through code generation, apart from boilerplate, I think it is because we new SOM - service object mapper. 通常代码生成支持服务,除了样板,我认为这是因为我们新的SOM - 服务对象映射器。 So again, what are the reasons for wervices rather than objects? 再说一次,wervices而不是对象的原因是什么?

The main difference between distributing services vs distributing objects is that services and their operations are by definition coarse-grained while objects are by default fine-grained. 分发服务与分发对象之间的主要区别在于服务及其操作按定义粗粒度,而对象默认是细粒度的。

When doing remote calls, network latency is a fact and the more coarse is your interface, the better. 进行远程呼叫时,网络延迟是一个事实,您的界面越粗糙越好。 Service-oriented patterns and practices focus on building such interfaces. 面向服务的模式和实践专注于构建此类接口。

So, to sum up, the problem is not in the technology or protocol (binary vs XML) but rather in usage scenarios. 因此,总而言之,问题不在于技术或协议(二进制与XML),而在于使用场景。 You can create 'services' in CORBA and do old-school distributed objects programming in WCF, but the former seems to be more biased towards objects while the latter -- towards services... 您可以在CORBA中创建“服务”并在WCF中进行旧式分布式对象编程,但前者似乎更偏向于对象,而后者 - 对服务...

Distributed objects and remote procedure calls are kind of like shared state between processes, while Services are self contained. 分布式对象和远程过程调用有点像进程之间的共享状态,而服务是自包含的。

It can be compared to the relationship between normal OOP in a shared state language, and a language using the Actor model and no shared state (like in Erlang, where you have a lot of light-weight processes not sharing anything, but communicating through messages only). 它可以与共享状态语言中的普通OOP和使用Actor模型的语言之间的关系进行比较,并且没有共享状态(比如在Erlang中,您有很多轻量级进程不共享任何内容,但通过消息进行通信只要)。 The Actor model approach is much less complex, and can give you benefits in relation to concurrency etc. Actor模型方法不那么复杂,并且可以为您提供与并发性等相关的好处。

IMHO, there is little difference at a high level. 恕我直言,在高层次上几乎没有什么区别。 But at an implementation level, distributed objects, CORBA, Java RMI, etc. leave a lot to be desired. 但是在实现层面,分布式对象,CORBA,Java RMI等等还有很多不足之处。 I tried to work with CORBA and later RMI in real production systems, and keeping versions in sync was a nightmare. 我尝试在实际生产系统中使用CORBA和后来的RMI,并保持版本同步是一场噩梦。

These days, I send messages and get responses. 这些天,我发送消息并得到回复。

Distributed object means what? 分布式对象意味着什么 Two copies of the same object which must be synchronized? 必须同步的同一对象的两个副本? two-phase commit to each change to the object? 每次更改对象的两阶段提交? Complex. 复杂。

Moving an object around the network from location to location? 在网络中将对象从一个位置移动到另一个位置? In this case, you've got to be sure that "ownership" is correctly relinquished. 在这种情况下,您必须确保“所有权”被正确放弃。 How does one host know the other has changed state on the object? 一个主机如何知道另一个主机已经改变了对象的状态? It has to be -- what -- copied back again? 它必须 - 什么 - 再次复制?

The "distributed object" model rapidly gets complex. “分布式对象”模型很快变得复杂。

A service -- at it's simplest -- means that exactly one host offers the service and maintains state. 服务 - 最简单 - 意味着只有一个主机提供服务并维护状态。 Relational databases have exemplified this services model for decades. 几十年来,关系数据库已经证明了这种服务模型。 As do other traditional services (ie, email, NIS, etc.) 和其他传统服务一样(例如,电子邮件,NIS等)

With one host offering services, there's no synchronization among copies, no duplication and very limited complexity. 有一个主机提供服务,副本之间没有同步,没有重复和非常有限的复杂性。

"why should we have something so procedural at higher level" “我们为什么要在更高层次上拥有如此程序化的东西”

You don't have something procedural at a higher level. 你没有更高层次的程序。

You have an object (the host that offers the services) with multiple methods. 您有一个具有多种方法的对象(提供服务的主机)。 It's perfectly object-oriented. 它完全是面向对象的。

It's -- generally -- a Singleton , which makes life very simple. 它通常是一个单身人士 ,它让生活变得非常简单。

Why the contraposition? 为什么反对? Concepts of distributed services and distributed objects overlap greatly, if not entirely (and SOAP is object access protocol, after all). 分布式服务和分布式对象的概念即使不是完全重叠也很重要(毕竟SOAP是对象访问协议)。 WCF is one example of switching between 'web service' and 'remote object' by a single line of configuration. WCF是通过单行配置在“Web服务”和“远程对象”之间切换的一个示例。

Difference is mostly terminological, explained by historical areas of application. 差异主要是术语,由历史应用领域解释。

(Szymon wrote essentially the same eariler) (Szymon基本上写了相同的预告片)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM