近一段时间,看了下ICE相关文档,联系到目前项目中使用的情况,记录一下自己的一些理解。
从两个方面论述,一个是运行期质量属性。一个是关于轮子的问题。
一、运行期质量属性
1.1、安全性
首先,项目组中大多采用copy方式从其他地方获得ICE Slice 文件,而一些不明就里人员在什么时候在方法的签名前 加上了 idempotent 这个关键字,以致copy 人员也直接在所以方法签名的地方加上这个关键字。这个关键字的含义是 幂等性的含义,官网对这个解释的很清楚。那和安全性有什么关系呢?
因为被这个关键字修饰的方法是可幂等性调用的。所谓幂等性,调用一次和多次对服务端所产生的效果一致。基本上类似查询,较多一些,也可能牵涉到修改等。不能一概而论。这牵涉到重复调用的可能,Automatic Retries for Idempotent Operations。The benefit of the idempotent
keyword and the associated relaxation of retry semantics is that an invocation that otherwise might have raised an exception has at least one more chance to succeed. Furthermore, the application does not need to initiate the retry, and in fact the retry activities are completely transparent: if a subsequent retry succeeds, the application receives its results as if nothing went wrong. The invocation only raises an exception once Ice has reached its configured retry limits.
如果某些方法不适合重复调用的情况,那加上这个关键字将对业务处理上是错误的,数据完整性也得不到保证。当然,这种情况一般不会少见,因为出现重连的机会不会太多,特别是对于功能测试来说。然而一旦发布公网,网络环境的影响大大增加。系统往往出现了一些问题,而却重现时难以出现。这类问题很难去扑捉,定位。往往是,从头开始整个业务流程检查下来,浪费了人力,财力,结果可能是不了了之。
1.2、性能
当然,性能整个话题很广,很大。目前是缩小讨论的范围,定位在某个点上讨论,才有一些比对意义。这个点现在定位在连接管理上,连接使用。对于客户端代理,目前项目采用的stringified proxy 方式。问题就是,现在代理对象本身使用的是同一个连接(不考虑连接超时的情况下),意味着,这个代理对象的方法调用过程中,都是使用同一个连接。如果并发数上来的情况下,其他调用就要争用这个资源。势必增加调用时间。这时,可以考虑采用不同方法使用不同连接,或是同一个方法使用几个连接等来处理,具体的数目还需要综合性能测试标准。
二、关于轮子问题
2.1、协议压缩
ICE 已经提供好在同一个连接上使用数据压缩的功能,包括里面定义的数据类型,等最终会采用压缩,而目前项目中,在业务应用层次上做了一次自己的压缩。关于,这两者哪个会胜出在运行效率,开发复杂度,设计上等哪一个更好呢?
2.2、集群
分布式系统,ICE中间件 势必需要支持集群功能,ICEGrid 是个好东西,可惜,目前我还在了解阶段,因为目前项目系统已经开始自己搞自己的集群方案了。
看下ICEGrid 具有的功能:
- Location service(定位服务)
As an implementation of an Ice location service, IceGrid enables clients to bind indirectly to their servers, making applications more flexible and resilient to changing requirements.
- On-demand server activation(命令行方式服务激活)
Starting an Ice server process is called server activation. IceGrid can be given responsibility for activating a server on demand, that is, when a client attempts to access an object hosted by the server. Activation usually occurs as a side effect of indirect binding, and is completely transparent to the client.
- Application distribution(应用分布式)
IceGrid provides a convenient way to distribute your application to a set of computers, without the need for a shared file system or complicated scripts. Simply configure an IcePatch2 server and let IceGrid download the necessary files and keep them synchronized.
- Replication and load balancing(复制与负载均衡)
IceGrid supports replication by grouping the object adapters of several servers into a single virtual object adapter. During indirect binding, a client can be bound to an endpoint of any of these adapters. Furthermore, IceGrid monitors the load on each computer and can use that information to decide which of the endpoints to return to a client.
- Sessions and resource allocation(会话与资源分配)
An IceGrid client establishes a session in order to allocate a resource such as an object or a server. IceGrid prevents other clients from using the resource until the client releases it or the session expires. Sessions enhance security through the use of an authentication mechanism that can be integrated with a Glacier2 router.
- Automatic failover(自动故障转移)
Ice supports automatic retry and failover in any proxy that contains multiple endpoints. When combined with IceGrid's support for replication and load balancing, automatic failover means that a failed request results in a client transparently retrying the request on the next endpoint with the lowest load.
- Dynamic queries(动态查询)
In addition to transparent binding, applications can interact directly with IceGrid to locate objects in a variety of ways.
- Status monitoring(状态监控)
IceGrid supports Slice interfaces that allow applications to monitor its activities and receive notifications about significant events, enabling the development of custom tools or the integration of IceGrid status events into an existing management framework.
- Administration(管理)
IceGrid includes command-line and graphical administration tools. They are available on all supported platforms and allow you to start, stop, monitor, and reconfigure any server managed by IceGrid.
- Deployment(部署)
Using XML files, you can describe the servers to be deployed on each computer. Templates simplify the description of identical servers.
- Database Independence(数据库独立)
By default, IceGrid uses a Freeze database to store its state. However, you can configure IceGrid to use a different database, such as MySQL (among others).
As grid computing enters the mainstream and compute servers become commodities, users expect more value from their applications. IceGrid, in cooperation with the Ice run time, relieves you of these low-level tasks to accelerate the construction and simplify the administration of your distributed applications.
三、后记
ICE本身提供的几个服务还没深入学习,看来,如果系统中采用ICE,最好还是更深入了解一下这些服务,毕竟是同一个家族。相比其他可能底层会有较多的优化措施。比如:性能上,安全性等。