Layered Design of RSF Distributed RPC Service Framework

What is RSF?

    A highly available, high-performance, lightweight distributed service framework. Support disaster recovery, load balancing, and clustering. A typical application scenario is to deploy the same service on multiple servers to provide request and response message notifications. Using RSF can be point-to-point calls, but also distributed calls. In terms of deployment method: it can be used with the registration center or independently.

 

origin

    The core idea of ​​RSF refers to excellent frameworks such as Taobao HSF and Dubbo. The functions are generally similar, but the implementation logic is completely different. So there is no historical baggage. In general, compared to Taobao HSF, there is less historical burden, and it is lighter than Dubbo. It also supports virtual computer rooms, which can save a lot of bandwidth costs for products deployed in multiple computer rooms, and also reduce remote call time.

    Although RSF is not very different from the two predecessors in function, the most intuitive feeling of using RSF is that it is simple and convenient, with less configuration, less dependence, and powerful functions.

 

Features

    The biggest feature of RSF is that it can still be maintained under the support of powerful functions: the simplest and lightest. Let's talk about the characteristics of RSF lightly.

    Simple and easy (three ones): 1 line of code to publish service, 1 line of code to subscribe service, 1 line of code to use service    

    Thin and light: RSF is built on Hasor, and also relies on netty and groovy. Therefore, the total number of imported JAR packages including RSF is only 5, and the size of RSF is only about  700KB  .

working principle

technology sharing

    RSF is a distributed RPC service framework specially designed for cluster and high-availability systems. The service provider can be a cluster, and the service consumer can also be a cluster, and it is ok to mix the two in a cluster. At the same time, in order to enhance the disaster recovery RSF's registration center, it also supports clusters.

    Therefore, the service system based on RSF will not have any single point problem.

frame layering

    The architecture design of RSF follows a clear top-down hierarchical design, and each layer has dedicated work responsibilities. It is roughly divided into  9  levels. They are as follows: , you can also understand that this is the architectural design of RSF. technology sharing    The first layer: It is the service in the business system. The state of a service can be a provider (Provider), a consumer (Customer), or both coexist. In short, at this layer, what appears is not the service interface, but the implementation of the service interface .

    The second layer: is an application to the framework of the access layer. It is divided into two parts: Provider and Consumer.

    For the provider (Provider), this layer is an interactive API of the framework, which is responsible for extracting the service interface information so that the RSF framework can identify it . For consumers, the purpose of this layer is to dynamically proxy the service interface. Intercept all remote method calls through a proxy , similar to AOP.

    Layer 3: All interface calls from dynamic agents in this layer will be uniformly converted into RsfRequest, and the return value of the method will also be encapsulated into RsfResponse. It can be said that this layer is specially designed for extensibility , and developers can expand around the RsfFilter, RsfRequest, and RsfResponse interfaces in this layer.

    The fourth layer: This is a typical responsibility chain . The beginning of the responsibility chain is to undertake the call request, and the end of the responsibility chain is to undertake the method invocation. Developers can do almost anything they want throughout the chain of responsibility. You can interrupt the entire RPC and mock the data yourself. You can also call other services and return results.

    The fifth layer: This layer is also the exclusive design of the customer (Customer), this layer is a more important place, it is responsible for maintaining the management and providing the IP address of the service. For example: we have 1 service and this service has 10 service providers. Then the service addresses and port information of these 10 service providers are maintained at this layer. When performing a remote call, this layer will provide the IP address.

    It is necessary to expand on the operation of providing an IP address. To QoS flow control, cross-machine room invocation, service routing. These very important functions are supported by this layer. This layer is expressed in one sentence: it is the address manager .

    The sixth layer: This layer is the most appropriate to use the " scheduler " to summarize the description.

    For the Provider, this layer provides a Server-based protection barrier based on the queue. This protective barrier can ensure that when encountering the crazy call request of the Client, it can be reasonably rejected to ensure that the Server itself will not be overwhelmed. For the consumer (Customer), a request manager is provided at this layer, and a controller for maximum request concurrency is provided.

    This layer can be said to be the central nerve of RSF, because the scheduler is the final implementation of the RSF threading model. There will be a special article about the threading model later ( https://my.oschina.net/u/1166271/blog/779361 ).

    Layer 7: It provides serialization functions, and developers want to customize serialization rules. It is also supported by this layer. The default RSF uses Hessian 4.0.7 as the default serialization library. At the same time, the framework has built-in Java and Json strategies to choose from.

    If you use Hessian when requesting, the data response wants to be in JSON. can also be supported.

    The eighth layer: This layer is the bottom layer and is responsible for the transmission of network data. Therefore, in this layer RSF has built-in a relatively complete RSF data transmission protocol. The article is here: https://my.oschina.net/u/1166271/blog/342091

    The ninth layer: It is the Socket network communication of the computer. This layer can be either TCP or UDP if you want. However, RSF uses TCP long links.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325238040&siteId=291194637