Distributed service communication system
By introducing Hessian lightweight communication framework and TCP protocol support in the distributed service communication system, combined with service contract and configuration management, the problem of low communication performance between microservices is solved, and high-performance and reliable remote calls are achieved.
Patent Information
- Application Number
- CN202411211312.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-12
AI Technical Summary
In the RestTemplate mode or openFeign mode of existing inter-microservice communication, the high bandwidth usage and the increased network overhead caused by the Http communication protocol and the three-time handshake increase affect the performance of the system.
A distributed service communication system was designed, including service providers, service consumers and registration and discovery centers. Through the Hessian lightweight communication framework, TCP protocol support is added on the basis of Http, service contracts and configuration management are realized, and Kafka is introduced for Asynchronous log summary, supporting retry and circuit breaking strategies for service calls.
Improve the performance of remote calls between microservices, reduce network overhead, and improve system reliability and observability through service contracts and configuration management.
Smart Images

Figure CN118945211A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed service communication framework, and in particular to a distributed service communication system. Background Art
[0002] The Distributed Service Communication Framework (LSF) is dedicated to solving the service call problem between distributed systems and provides a transparent, high-performance RPC service call solution. LSF is suitable for scenarios where systems built on JAVA interact with each other. The underlying non-blocking communication framework Netty TCP is integrated to achieve an efficient remote service call solution.
[0003] The current mainstream openFeign implementation solutions include:
[0004] At the project startup stage, the OpenFeign framework will initiate an active package scanning process to scan and load all interfaces modified by the @FeignClient annotation from the specified directory.
[0005] OpenFeign will generate a dynamic proxy object for each FeianClien interface, namely the FeianProxvService in the figure. This proxy object belongs to the instance of the interface modified by the FeignClient annotation in the inheritance relationship.
[0006] This dynamic proxy object will be added to the Spring context and injected into the corresponding service, which is the LocalService service in the figure.
[0007] LocalService will initiate the underlying method call. In fact, this method call will be taken over by the proxy object generated by OpenFeign, which will initiate a remote service call and return the result of the call to LocalService.
[0008] At present, the mainstream microservice application framework selection is mainly based on springboot, but its RestTemplate mode or openFeign mode for communication between microservices is based on the Http communication protocol at the bottom layer. The communication message bandwidth occupies a high level, and a short connection is used in the Http1.1 protocol mode. Each time the communicating parties establish a request, a three-way handshake is required, which invisibly increases the network overhead. Summary of the invention
[0009] In view of the above problems, the present invention is proposed to provide a distributed service communication system that overcomes the above problems or at least partially solves the above problems.
[0010] According to one aspect of the present invention, there is provided a distributed service communication system, the communication system comprising:
[0011] Service providers, service consumers and registration discovery centers;
[0012] The service provider and the service consumer determine a service contract;
[0013] The service provider implements the service contract by coding, and implements the service contract and service configuration by annotation declaration;
[0014] Service consumers consume services based on service contracts and subscribe to changes in service configuration and provider node list information.
[0015] Optionally, the service provider implements the service contract by coding, and implements the service contract and service configuration by annotation declaration, including:
[0016] When the service provider application is started, the framework automatically registers the service contract and service configuration information, and the subsequent service configuration library information on the platform shall prevail;
[0017] When a server in the service provider's application cluster goes down or a new server is added, the service registration and discovery center will be notified;
[0018] The service registration and discovery center will further notify the service consumer.
[0019] Optionally, the service consumer and service provider count the response time of the service call and the call details, print them to a local log file, and asynchronously aggregate them to a log and statistics platform through Kafka.
[0020] Optionally, the distributed service communication system further includes: a configuration center, configured to provide service configuration information.
[0021] Optionally, the service configuration information specifically includes: IP information, routing information and parameter information.
[0022] Optionally, the distributed service communication system also includes: ElasticSearch, which is used to provide log recording and viewing services.
[0023] The present invention provides a distributed service communication system, the communication system includes: a service provider, a service consumer and a registration discovery center; the service provider and the service consumer determine a service contract; the service provider encodes and implements the service contract, and implements the service contract and service configuration through annotation declaration; the service consumer consumes the service based on the service contract, and subscribes to the information change of the service configuration and the provider node list. Based on the Hessian lightweight communication framework, support for the TCP protocol is added on the basis of HTTP to improve the performance of remote calls between microservices.
[0024] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0026] Figure 1 A configuration diagram of a distributed service communication system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0028] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.
[0029] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0030] like Figure 1 As shown, a distributed service communication system includes: a service provider, a service consumer, and a registration and discovery center.
[0031] The service provider and the consumer determine the service contract. The service provider implements the service contract through coding, and implements the service contract and necessary service configuration through annotation declaration. When the service provider application starts, the framework automatically registers the service contract and service configuration information, and the service configuration library information on the platform shall prevail in the future. When a server crashes or a new server is added in the service provider application cluster, the service registration and discovery center will be notified. The service registration and discovery center will further notify the service consumer. The service consumer consumes services based on the service contract and subscribes to changes in service configuration and provider node list information. The service consumer and the service provider count the response time of the service call, as well as the call details, etc., print them to the local log file, and asynchronously aggregate them to the log and statistics platform through Kafka.
[0032] Configuration center: provides service configuration information, including IP information, routing information, parameter information, etc.
[0033] Registration and Discovery Center: Provides registration and discovery of services.
[0034] Service provider: registers the service with the registration center.
[0035] Service Consumer: Service consumers consume services based on service contracts and subscribe to changes in service configuration and provider node list information.
[0036] ElasticSearch: Provides logging and viewing services.
[0037] Specific implementation plan:
[0038] The service provider provides a service contract interface interface, and uses the annotation @Convention(name="Contract Name", description="Description") on the interface to declare the service. As the service provider application starts, the service is exposed through the BeanContainerServicesPublisher in the spring framework, and LSF automatically registers the service contract and configuration information with the service management platform. In addition, the service provider implements the declared interface, and uses @ImplConvention(convention=service.class,serverCode="") in the implementation class to declare the implemented contract. The specific implementation method name in the implementation class is annotated with @ServiceName(timeout=timeout time, retryTimes=retry times description=description). If multiple interfaces are implemented, then convention needs to be specified. If the service interface has multiple implementation classes, then the specific serverCode needs to be specified. In the springframework environment, the service consumer is completed through the @Reference annotation. The interaction between the consumer and the service provider is serialized based on Hessian. The entity object in the message must implement the Serializable interface to ensure the normal serialization and deserialization of the message.
[0039] LSF has a retry function. When the consumer initiates a call, if the retry times retryTimes is set and is greater than 0, multiple requests will be made to the server in the event of network anomalies. The request timeout is the maximum waiting time under the retry times to avoid the situation where each request times out. For example, if a single request actually takes 20ms, the timeout is set to 50ms, and the number of retries is set to 3 times, then at most 2 retries can actually be made. Therefore, adjusting the appropriate timeout is crucial for the normal response of the service.
[0040] LSF introduces a service method-level fuse strategy, that is, when an exception occurs when calling a service method and reaches the set exception threshold, access to the service method will be prohibited for a period of time (the fuse state is switched from the normal CLOSE state to the OPEN state at this time). After a normal period of time, a small number of requests will be allowed (the fuse state is converted to HALF OPEN at this time). If a high exception ratio still occurs, access will continue to be prohibited for a period of time (the fuse state is switched back to OPEN), otherwise the access restriction will be lifted (the fuse is set back to the normal state CLOSE).
[0041] Beneficial effects: Based on the Hessian lightweight communication framework, support for the TCP protocol is added on the basis of HTTP to improve the performance of remote calls between microservices.
[0042] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A distributed service communication system, characterized in that: The communication system comprises: Service providers, service consumers and registration discovery centers; The service provider and the service consumer determine a service contract; The service provider implements the service contract by coding, and implements the service contract and service configuration by annotation declaration; Service consumers consume services based on service contracts and subscribe to changes in service configuration and provider node list information.
2. A distributed service communication system according to claim 1, characterized in that: The service provider implements the service contract by coding, and implements the service contract and service configuration through annotation declaration, including: When the service provider application is started, the framework automatically registers the service contract and service configuration information, and the subsequent service configuration library information on the platform shall prevail; When a server in the service provider's application cluster goes down or a new server is added, the service registration and discovery center will be notified; The service registration and discovery center will further notify the service consumer.
3. A distributed service communication system according to claim 1, characterized in that: The service consumer and service provider count the response time of the service call and the call details, print them to the local log file, and asynchronously aggregate them to the log and statistical platform through Kafka.
4. A distributed service communication system according to claim 1, characterized in that: The distributed service communication system also includes: a configuration center, which is used to provide service configuration information.
5. A distributed service communication system according to claim 4, characterized in that: The service configuration information specifically includes: IP information, routing information and parameter information.
6. A distributed service communication system according to claim 1, characterized in that: The distributed service communication system also includes: ElasticSearch, which is used to provide log recording and viewing services.
