Microservice communication methods, systems, devices, equipment, and storage media

By employing lightweight communication protocols and long-lived connection mechanisms between microservice layers, reusable communication connections are established, solving the performance bottleneck problem of microservice systems in high-concurrency scenarios and improving system performance and throughput.

CN116614486BActive Publication Date: 2025-10-31CHINA MERCHANTS BANK
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310595395.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2025-10-31
Estimated Expiration
2043-05-23

AI Technical Summary

Technical Problem

In high-concurrency scenarios, the frequent creation and destruction of short HTTP connections between microservices leads to high communication overhead, low system performance and throughput, and performance bottlenecks.

Method used

A lightweight communication protocol and long-connection mechanism are adopted to establish reusable communication connections, replacing the traditional short-connection mechanism that is used and destroyed as needed. A distributed registry center manages the node information and communication requirements of the microservice layer, determines the communication path, and enables communication between adjacent microservice layers.

Benefits of technology

It reduces the number of connections created between microservice layers, saves communication connection overhead, improves the overall performance and throughput of the system, and eliminates performance bottlenecks in concurrent scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116614486B_ABST
    Figure CN116614486B_ABST
Patent Text Reader

Abstract

This application discloses a microservice communication method, system, apparatus, device, and storage medium. The method includes the steps of: obtaining node information of adjacent microservice layers to be communicated, and obtaining the communication requirements of the adjacent microservice layers; determining a communication path between the adjacent microservice layers based on the communication requirements and the node information; establishing a reusable communication connection using a lightweight communication protocol and a long-connection mechanism based on the communication path; and performing communication between the adjacent microservice layers based on the reusable communication connection. This application achieves the effect of determining the communication path between adjacent microservice layers based on the node information and communication requirements of the adjacent microservice layers to be communicated, and establishing a reusable communication connection using a lightweight communication protocol and a long-connection mechanism, thereby achieving communication between adjacent microservice layers based on reusable communication connections and avoiding the high overhead caused by short, disposable connections.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of microservice communication technology, and in particular to a microservice communication method, system, apparatus, device and storage medium. Background Technology

[0002] Microservice architecture distributed systems deployed in container cloud environments are widely used in real life. They break down the original overall system containing multiple services into multiple microservices and establish connections and calls between microservices in a layer-by-layer interactive manner. Among them, the interaction between microservices is mainly based on HTTP calls.

[0003] However, HTTP communication connections have the following problems: due to the frequent communication of microservices, if an instant short connection is established based on the HTTP protocol, the frequent creation and destruction of the connection will result in a large communication overhead, low overall system performance and throughput, and high resource consumption.

[0004] Therefore, in situations with high concurrency and frequent communication between microservices, the communication overhead of using short-lived HTTP connections is large, and it leads to low overall performance and throughput of the system where the microservices reside. For example, it can cause performance bottlenecks in high-concurrency scenarios such as flash sales, instant messaging, online customer service, and lotteries. Summary of the Invention

[0005] In view of this, this application provides a microservice communication method, system, apparatus, device and storage medium, aiming to improve the overall performance and throughput of the system where the microservice resides, so as to eliminate the performance bottleneck of the system where the microservice resides in high concurrency scenarios.

[0006] To achieve the above objectives, this application provides a microservice communication method, which includes the following steps:

[0007] Obtain the node information of the adjacent microservice layer to be communicated with, and obtain the communication requirements of the adjacent microservice layer;

[0008] Based on the communication requirements and the node information, determine the communication path between the adjacent microservice layers;

[0009] Based on the communication path, a reusable communication connection is established using a lightweight communication protocol and a long connection mechanism, and communication is performed between the adjacent microservice layers based on the reusable communication connection.

[0010] For example, the step of determining the communication path between adjacent microservice layers based on the communication requirements and the node information includes:

[0011] Based on the communication requirements and the node information, determine the currently available nodes in the adjacent microservice layer;

[0012] Based on a preset path selection algorithm and the currently available nodes, a communication path is determined between adjacent microservice layers, wherein the communication path covers all currently available nodes.

[0013] For example, the adjacent microservice layer includes an upper microservice layer and a lower microservice layer, the communication path includes a direct communication path, and the step of determining the communication path between the adjacent microservice layers according to a preset path selection algorithm and the currently available nodes includes:

[0014] Based on the preset path selection algorithm and the currently available nodes, a first mapping relationship is established between each node of the upper microservice layer and each node of the lower microservice layer through a distributed registration center, and the direct communication path between the adjacent microservice layers is determined based on the first mapping relationship.

[0015] The communication protocol used when communicating via the direct communication path includes at least the TCP protocol.

[0016] For example, if the communication path is a direct communication path, then the step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism includes:

[0017] Based on the direct communication path, determine the communication node to be communicated in the upper microservice layer, and determine the distribution node to be distributed that has the first mapping relationship with the communication node to be communicated in the lower microservice layer;

[0018] According to the preset load balancing algorithm, the requests in the nodes to be communicated are evenly distributed to each node to be distributed, and a reusable communication connection is established between the nodes to be communicated and each node to be distributed using a lightweight communication protocol and a long connection mechanism.

[0019] For example, the adjacent microservice layers include an upper microservice layer and a lower microservice layer, the communication path includes a relay communication path, and the method further includes the step of determining the communication path between the adjacent microservice layers according to a preset path selection algorithm and the currently available nodes.

[0020] Based on the preset path selection algorithm and the currently available nodes, the routes set in the next microservice layer are used as relays, and based on the relays, a second mapping relationship is determined between each node of the previous microservice layer and each node of the next microservice layer.

[0021] Based on the second mapping relationship, the relay communication path between the adjacent microservice layers is determined;

[0022] The communication protocol used when communicating through the relay communication path includes at least the HTTP protocol.

[0023] For example, the communication path includes a direct communication path and a relay communication path. The step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism includes:

[0024] Based on the direct communication path, a reusable communication connection is established using a lightweight communication protocol and a long connection mechanism.

[0025] After the load on the direct communication path reaches a preset threshold, the reusable communication connection is established based on the direct communication path and the relay communication path.

[0026] For example, to achieve the above objectives, this application also provides a microservice communication system, the system including an input terminal, an intermediate processing microservice layer, and an output terminal:

[0027] The intermediate processing microservice layer includes at least two microservice layers with sequential processing order and a distributed registry center;

[0028] The distributed registration center is used to receive node information from different microservice layers and register the node addresses of adjacent microservice layers to be communicated based on the node information, so that the intermediate processing microservice layer can establish direct communication between the adjacent microservice layers.

[0029] The input terminal and the output terminal can be the same terminal, used to communicate and interact with the intermediate processing microservice layer.

[0030] The communication protocol between the input end and the output end and the intermediate processing microservice layer includes long connection mechanism and short connection mechanism.

[0031] For example, to achieve the above objectives, this application also provides a microservice communication device, the device comprising:

[0032] The acquisition module is used to acquire node information of the adjacent microservice layer to be communicated with, and to acquire the communication requirements of the adjacent microservice layer.

[0033] The determination module is used to determine the communication path between adjacent microservice layers based on the communication requirements and the node information.

[0034] The communication module is used to establish a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism, and to communicate between adjacent microservice layers based on the reusable communication connection.

[0035] For example, to achieve the above objectives, this application also provides a microservice communication device, the device comprising: a memory, a processor, and a microservice communication program stored in the memory and executable on the processor, the microservice communication program being configured to implement the steps of the microservice communication method as described above.

[0036] For example, to achieve the above objectives, this application also provides a computer storage medium storing a microservice communication program, which, when executed by a processor, implements the steps of the microservice communication method described above.

[0037] Compared to related technologies where high concurrency and frequent communication between microservices result in high communication overhead from short-lived HTTP connections, leading to lower overall system performance and throughput, this application addresses the issue by: acquiring node information of adjacent microservice layers to be communicated with, and acquiring the communication requirements of those adjacent microservice layers; determining the communication path between the adjacent microservice layers based on the communication requirements and the node information; establishing a reusable communication connection using a lightweight communication protocol and a long-lived connection mechanism based on the communication path; and conducting communication between the adjacent microservice layers based on the reusable communication connection. In other words, the application determines the communication path between the adjacent microservice layers based on the acquired node information and communication requirements of the adjacent microservice layers to be communicated with. The communication path between adjacent microservice layers is optimized by using a lightweight communication protocol and a long-lived connection mechanism to establish reusable communication connections. These reusable connections are then used for communication between adjacent microservice layers, thus avoiding the need for short-lived connections. By replacing the short-lived connections with reusable long-lived connections, the number of times connections need to be created between microservice layers is reduced, saving the overhead and time required for short-lived connections. This improves the overall performance and throughput of the system containing the microservice layers, thereby eliminating performance bottlenecks in concurrent scenarios. Attached Figure Description

[0038] Figure 1 This is a flowchart illustrating the first embodiment of the microservice communication method of this application;

[0039] Figure 2 This is a schematic diagram of the inter-service communication and interaction framework of the microservice communication method in this application;

[0040] Figure 3 This is a schematic diagram of the direct communication interaction between service layers in the microservice communication method of this application;

[0041] Figure 4 This is a schematic diagram of the service communication framework for the microservice communication method in this application;

[0042] Figure 5 This is a flowchart illustrating the second embodiment of the microservice communication method of this application;

[0043] Figure 6 This is a schematic diagram illustrating the application of the distributed registry center in the microservice communication method of this application;

[0044] Figure 7 This is a schematic diagram of the hardware operating environment involved in the embodiments of this application.

[0045] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0046] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0047] This application provides a microservice communication method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the microservice communication method of this application.

[0048] This application provides embodiments of a microservice communication method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order. For ease of description, the execution entity describing each step of the microservice communication method is omitted below. The microservice communication method includes:

[0049] Step S110: Obtain the node information of the adjacent microservice layer to be communicated with, and obtain the communication requirements of the adjacent microservice layer;

[0050] For example, distributed systems based on container cloud environments with microservice architecture are widely used. The system is divided into many microservices, and the communication between microservices is mainly via HTTP calls. The internal processing architecture of this system, which consists of multiple microservices, is an application scenario in this embodiment.

[0051] When the system is split into multiple microservices (there are more than or equal to 2 microservices in the system), it is equivalent to building multiple microservice layers with a sequential processing order. In this embodiment, the microservice layer refers to the internal architecture of the system with a sequential processing order.

[0052] In this system architecture, adjacent microservice layers typically communicate primarily via HTTP calls. Based on the HTTP protocol, a communication connection is created each time an adjacent microservice layer communicates, and this connection is cancelled after the communication is completed. Due to the high overhead and resource consumption of this short-connection HTTP communication, and the frequent communication between adjacent microservice layers, connections are frequently created and destroyed, resulting in high overhead and low overall system performance and throughput. The problems with the connection communication used by this short-connection mechanism are the main problems that need to be solved in this embodiment.

[0053] When adjacent microservice layers establish communication connections, they typically establish interactive communication connections between nodes within the adjacent microservice layers, connecting the upper microservice layer to the lower microservice layer. This is achieved by configuring appropriate routes between them. For details, please refer to [reference needed]. Figure 2 The system architecture, Figure 2 The left side of the middle section represents the external input terminal of the system. It connects to the system via HTTP communication and responds to the input terminal's requests through multiple microservice layers within the system. The communication process is completed in a hierarchical interactive manner, and the corresponding results are output. These output results are then returned to the external input terminal.

[0054] In summary, since the communication connections between adjacent microservice layers affect the overall performance of the system in the current application scenario, it is necessary to make corresponding adjustments to the communication connections between adjacent microservice layers in the system in order to reduce the resource consumption caused by the HTTP short connection mechanism and improve the system throughput.

[0055] Therefore, when establishing communication connections between microservice layers within the system, the node information of the adjacent microservice layers to be communicated and their corresponding communication requirements are first obtained. The adjacent microservice layers can be any adjacent microservice layers within the system. For example, the system includes three microservice layers A, B, and C. In this embodiment, the adjacent microservice layers obtained include A and B, and B and C.

[0056] When the system receives an external request, it will call the desired microservice based on the actual request. Therefore, when obtaining the microservice layer to be communicated, it is also necessary to obtain the corresponding communication requirements at the same time. These communication requirements are mainly used to indicate the communication interaction process that needs to be completed and the request for the required microservice.

[0057] Step S120: Determine the communication path between the adjacent microservice layers based on the communication requirements and the node information;

[0058] Based on communication requirements and node information, determine the communication path between adjacent microservice layers.

[0059] In this embodiment, the communication path between adjacent microservice layers may include the following two aspects: nodes between adjacent microservice layers establish corresponding communication paths through routing as an intermediary, as detailed in the following example. Figure 2 Nodes in adjacent microservice layers directly establish corresponding communication paths; see the details below. Figure 3 .

[0060] The communication paths between adjacent microservice layers differ, allowing for the use of different communication protocols for connection. For example, according to... Figure 3 It can be seen that when a node in microservice layer A establishes a communication connection with a node in microservice layer B, the TCP protocol is used to establish the corresponding communication connection; for example, according to Figure 2 It can be seen that when a node in microservice layer A establishes a communication connection with a node in microservice layer B, the HTTP protocol is used to establish the corresponding communication connection.

[0061] In this embodiment, to avoid the overhead of frequent connection creation caused by the short connection mechanism in the HTTP protocol, it is necessary to change the current communication architecture of the microservice layer and propose a new service communication framework, which can be referred to in detail. Figure 4 ,according to Figure 4 Yes, compared to the traditional communication framework between microservice layers (see reference...). Figure 2 The communication framework shown here adds a corresponding distributed registry center to the traditional microservice layer framework. The distributed registry center manages the nodes between adjacent microservice layers in a unified manner and establishes direct communication paths between nodes. The nodes establish communication connections using the TCP protocol and retain the communication connections via routing in the traditional communication process. That is, different communication protocols can be used in this service communication framework.

[0062] In summary, determining the corresponding communication paths between microservice layers includes the communication paths connecting nodes in adjacent microservice layers, as well as the communication paths between nodes that communicate via routing.

[0063] It should be noted that, in Figure 4 In the service communication framework, the main focus is on establishing direct communication connections between nodes.

[0064] Step S130: Based on the communication path, establish a reusable communication connection using a lightweight communication protocol and a long connection mechanism, and conduct communication between adjacent microservice layers based on the reusable communication connection.

[0065] Based on the above, Figure 4In the service communication framework, the communication path for establishing direct communication connections between nodes can be determined. Then, a reusable communication connection can be established using a lightweight communication protocol and a long connection mechanism, so that communication can be carried out between microservice layers based on this communication connection.

[0066] Based on the characteristics of the long connection mechanism, once the corresponding lightweight communication protocol is established, the communication connection is retained and not destroyed. At the same time, the communication connection can be reused when the adjacent microservice layers communicate with each other in the future.

[0067] Compared to related technologies where high concurrency and frequent communication between microservices result in high communication overhead from short-lived HTTP connections, leading to lower overall system performance and throughput, this application addresses the issue by: acquiring node information of adjacent microservice layers to be communicated with, and acquiring the communication requirements of those adjacent microservice layers; determining the communication path between the adjacent microservice layers based on the communication requirements and the node information; establishing a reusable communication connection using a lightweight communication protocol and a long-lived connection mechanism based on the communication path; and conducting communication between the adjacent microservice layers based on the reusable communication connection. In other words, the application determines the communication path between the adjacent microservice layers based on the acquired node information and communication requirements of the adjacent microservice layers to be communicated with. The communication path between adjacent microservice layers is optimized by using a lightweight communication protocol and a long-lived connection mechanism to establish reusable communication connections. These reusable connections are then used for communication between adjacent microservice layers, thus avoiding the need for short-lived connections. By replacing the short-lived connections with reusable long-lived connections, the number of times connections need to be created between microservice layers is reduced, saving the overhead and time required for short-lived connections. This improves the overall performance and throughput of the system containing the microservice layers, thereby eliminating performance bottlenecks in concurrent scenarios.

[0068] For example, refer to Figure 5 , Figure 5 This is a flowchart illustrating the second embodiment of the microservice communication method of this application. Based on the first embodiment of the microservice communication method of this application described above, a second embodiment is proposed, wherein the method further includes:

[0069] Step S210: Based on the communication requirements and the node information, determine the currently available nodes in the adjacent microservice layer;

[0070] Reference Figure 4As can be seen, in the service communication framework proposed in this embodiment, a distributed registry center is used to manage the nodes in adjacent microservice layers. It should be noted that the distributed registry center manages all nodes in all microservice layers within the entire service communication framework, and these all nodes include at least currently available nodes and currently unavailable nodes.

[0071] In the process of continuous communication and interaction within the microservice layer, there may be instances of adding, modifying, or deleting nodes. For example, due to service requirements, a corresponding node may be added to microservice layer A, or the computing power of some nodes in microservice layer A may be fully utilized, rendering them currently unusable. Therefore, taking microservice layer A as an example, it can be seen that the number of nodes in the microservice layer can change elastically during actual application. The number of currently available nodes and currently unavailable nodes will also change accordingly as the application progresses. Therefore, it is necessary to use a distributed registry center to manage all current nodes and limit the use of only the corresponding currently available nodes during each communication interaction to avoid using currently unavailable nodes, which could lead to poor transmission performance.

[0072] To better and more flexibly invoke nodes during the communication process, when using a distributed registry center, it is necessary to pre-register or subscribe to nodes in each microservice layer. This means first using the distributed registry center to obtain information about the nodes in each microservice layer. For example, refer to... Figure 6 It obtains node information in microservice layers A and B, including the source microservice layer of the node, the number of nodes contained in each microservice layer, and the currently available nodes in each microservice layer.

[0073] Step S220: Determine the communication path between the adjacent microservice layers according to the preset path selection algorithm and the currently available nodes, wherein the communication path covers all currently available nodes.

[0074] Currently, based on communication requirements and node information, the current nodes in the adjacent microservice layers are all defined as the currently available nodes in the adjacent microservice layers to be communicated. In the actual application process in the service framework, the adjacent microservice layers to be communicated may include multiple groups of adjacent microservice layers. That is, in each actual communication process, the node information read and the currently available nodes determined include nodes in multiple groups of microservice layers. The current available nodes of the adjacent microservice layers are the main application to determine the communication path in the current communication interaction process.

[0075] When determining the communication path between adjacent microservice layers based on the preset path selection algorithm and currently available nodes, the required communication path needs to cover all currently available nodes in the adjacent microservice layers.

[0076] For example, the adjacent microservice layer includes an upper microservice layer and a lower microservice layer, the communication path includes a direct communication path, and the step of determining the communication path between the adjacent microservice layers according to a preset path selection algorithm and the currently available nodes includes:

[0077] Step a: Based on the preset path selection algorithm and the currently available nodes, establish a first mapping relationship between each node of the upper microservice layer and each node of the lower microservice layer through the distributed registration center, and determine the direct communication path between the adjacent microservice layers based on the first mapping relationship.

[0078] The communication protocol used when communicating via the direct communication path includes at least the TCP protocol.

[0079] The preset path selection algorithm is a pre-defined algorithm for establishing communication connections between adjacent microservice layers. Its main selection rule is to connect all currently available nodes.

[0080] In this embodiment, a distributed registry center is used to obtain all currently available nodes in the corresponding adjacent microservice layers. The adjacent microservice layers include the upper microservice layer and the lower microservice layer. When determining the communication path, a direct communication path is established between each node in the upper microservice layer and each node in the lower microservice layer, using either traversal or a queue approach. The specific details of the determined communication paths can be found in [reference needed]. Figure 6 .

[0081] When determining the direct communication path between nodes in the upper microservice layer and nodes in the lower microservice layer, a corresponding first mapping relationship can be established between nodes in adjacent microservice layers. This first mapping relationship can be determined by the distributed registry center, i.e., the connection status of the direct communication path.

[0082] The purpose of the direct communication path is to avoid using short connection mechanisms and establish connections through relay routing. Therefore, the TCP protocol is used in the direct communication path.

[0083] For example, if the communication path is a direct communication path, then the step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism includes:

[0084] Step b: Based on the direct communication path, determine the communication node to be communicated in the upper microservice layer, and in the lower microservice layer, determine the distribution node that has the first mapping relationship with the communication node to be communicated;

[0085] After determining the direct communication path, the adjacent microservice layer that is currently to be communicated needs to first determine the communication node to be used in the previous microservice layer, and determine the corresponding distribution node to be established with the communication node in the next microservice layer. Among them, the node that has a first mapping relationship with the communication node in the next microservice layer is regarded as the distribution node. That is, it is equivalent to determining all the currently available nodes from the next microservice layer and taking all the currently available nodes as distribution nodes.

[0086] Step c: According to the preset load balancing algorithm, the requests in the nodes to be communicated are evenly distributed to each node to be distributed, and a reusable communication connection is established between the nodes to be communicated and each node to be distributed using a lightweight communication protocol and a long connection mechanism.

[0087] After identifying the nodes to be distributed, a lightweight communication protocol and a long connection mechanism can be used to establish a reusable communication connection between the nodes to be distributed and each node to be distributed.

[0088] In this process, after establishing a reusable communication connection, requests from the nodes to be communicated are evenly distributed to each node to be distributed according to a preset load balancing algorithm. That is, in the communication connection from the upper microservice layer to the lower microservice layer, all the communication content from the upper microservice layer is evenly distributed to each node in the lower microservice layer, thereby achieving the effect of load balancing for each node in the lower microservice layer.

[0089] This ensures load balancing between services: RandomNumber%NumOfPods+1. Each node in the next microservice layer is stateless, application processing is homogeneous, and each node can randomly accept requests and complete business processing. The load forwarding strategy is applicable to both short and long-lived connections, broadening its application scenarios.

[0090] For example, the adjacent microservice layers include an upper microservice layer and a lower microservice layer, the communication path includes a relay communication path, and the method further includes the step of determining the communication path between the adjacent microservice layers according to a preset path selection algorithm and the currently available nodes.

[0091] Step d: Based on the preset path selection algorithm and the currently available nodes, the route set in the next microservice layer is used as a relay, and based on the relay, a second mapping relationship is determined between each node of the previous microservice layer and each node of the next microservice layer;

[0092] Step e: Determine the relay communication path between the adjacent microservice layers based on the second mapping relationship;

[0093] The communication protocol used when communicating through the relay communication path includes at least the HTTP protocol.

[0094] When determining the communication path, a backup relay route communication path is also included. The route set in the next microservice layer can be used as a relay based on the preset path selection algorithm and the currently available nodes. Based on the relay, a second mapping relationship is established between each node of the upper microservice layer and each node of the lower microservice layer. The corresponding relay communication path is established based on the second mapping relationship. The HTTP protocol is used as the communication protocol for the relay communication path.

[0095] That is, in the service communication framework used in this embodiment, both long connections with direct communication paths are used, as well as corresponding communication connections relayed by routers. The traditional communication method is to use the HTTP protocol for communication connections, which will not be described in detail here.

[0096] For example, the communication path includes a direct communication path and a relay communication path. The step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism includes:

[0097] Step f: Based on the direct communication path, establish a reusable communication connection using a lightweight communication protocol and a long connection mechanism;

[0098] Step g: After the load on the direct communication path reaches a preset threshold, establish the reusable communication connection based on the direct communication path and the relay communication path.

[0099] In the service communication framework used in this embodiment, the communication paths include direct communication paths and relay communication paths. Therefore, when using this service communication framework, the two types of communication paths can be divided into a primary and secondary structure, with the direct communication path as the primary one. In actual communication applications, the direct communication path is used first, and the relay communication path is used as the secondary one. When the load of the direct communication path reaches a preset threshold, the relay path is used to continue the communication connection.

[0100] The load on the direct communication path primarily considers the load of the corresponding distributed registry. When establishing communication connections between adjacent microservice layers, the distributed registry needs to obtain the currently available nodes between the adjacent microservice layers to be communicated with in real time. This allows for dynamic adjustment of the nodes used in the direct communication path, and the communication requests from the upper microservice layer are evenly distributed to all nodes in the lower microservice layer for synchronous processing. Therefore, the distributed registry requires a relatively large amount of computing resources, resulting in a high load. There are also extreme cases where the distributed registry cannot be used, i.e., the load on the direct communication path reaches a preset threshold. In this case, when the distributed registry cannot be used, but the system still needs to process requests normally, the system needs to call the relay communication path to establish a communication connection under the corresponding HTTP protocol, thereby ensuring normal system communication and interaction.

[0101] In this embodiment, based on the communication requirements and the node information, the currently available nodes in the adjacent microservice layers are determined; based on the preset path selection algorithm and the currently available nodes, the communication path between the adjacent microservice layers is determined, wherein the communication path covers all currently available nodes. That is, a corresponding new communication framework is established, and based on the communication requirements and node information, all currently available nodes in the adjacent microservice layers are determined and applied to the actual communication connection between the adjacent microservice layers. This ensures that all nodes in the microservice layers in the current communication connection are put into use, avoiding the situation where some nodes in the microservice layers are idle, resulting in poor communication performance.

[0102] In addition, this application also provides a microservice communication device, which includes:

[0103] The acquisition module is used to acquire node information of the adjacent microservice layer to be communicated with, and to acquire the communication requirements of the adjacent microservice layer.

[0104] The determination module is used to determine the communication path between adjacent microservice layers based on the communication requirements and the node information.

[0105] The communication module is used to establish a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism, and to communicate between adjacent microservice layers based on the reusable communication connection.

[0106] For example, the determining module includes:

[0107] The first determining submodule is used to determine the currently available nodes in the adjacent microservice layer based on the communication requirements and the node information;

[0108] The second determining submodule is used to determine the communication path between the adjacent microservice layers based on a preset path selection algorithm and the currently available nodes, wherein the communication path covers all currently available nodes.

[0109] For example, the second determining submodule includes:

[0110] The first determining unit is configured to establish a first mapping relationship between each node of the upper microservice layer and each node of the lower microservice layer through a distributed registration center according to a preset path selection algorithm and the currently available nodes, and determine the direct communication path between the adjacent microservice layers according to the first mapping relationship; wherein the communication protocol used when using the direct communication path for communication includes at least the TCP protocol.

[0111] For example, the first determining unit includes:

[0112] The determining subunit is used to determine the communication node to be communicated in the upper microservice layer according to the direct communication path, and to determine the distribution node to be distributed in the lower microservice layer that has the first mapping relationship with the communication node to be communicated.

[0113] A subunit is constructed to distribute requests from the nodes to be communicated to each node to be distributed according to a preset load balancing algorithm, and to establish a reusable communication connection between the nodes to be communicated and each node to be distributed using a lightweight communication protocol and a long connection mechanism.

[0114] For example, the second determining submodule further includes:

[0115] The second determining unit is used to determine a second mapping relationship between each node of the upper microservice layer and each node of the lower microservice layer based on the route set in the next microservice layer as a relay according to the preset path selection algorithm and the currently available nodes.

[0116] The third determining unit is used to determine the relay communication path between the adjacent microservice layers according to the second mapping relationship; wherein the communication protocol used when using the relay communication path for communication includes at least the HTTP protocol.

[0117] For example, the communication module includes:

[0118] The first construction submodule is used to establish a reusable communication connection based on the direct communication path using a lightweight communication protocol and a long connection mechanism.

[0119] The second construction submodule is used to establish the reusable communication connection based on the direct communication path and the relay communication path after the load of the direct communication path reaches a preset threshold.

[0120] The specific implementation of the microservice communication device in this application is basically the same as the embodiments of the microservice communication method described above, and will not be repeated here.

[0121] In addition, this application also provides a microservice communication system, which includes an input end, an intermediate processing microservice layer, and an output end:

[0122] The intermediate processing microservice layer includes at least two microservice layers with sequential processing order and a distributed registry center;

[0123] The distributed registration center is used to receive node information from different microservice layers and register the node addresses of adjacent microservice layers to be communicated based on the node information, so that the intermediate processing microservice layer can establish direct communication between the adjacent microservice layers.

[0124] The input terminal and the output terminal can be the same terminal, used to communicate and interact with the intermediate processing microservice layer.

[0125] The communication protocol between the input end and the output end and the intermediate processing microservice layer includes long connection mechanism and short connection mechanism.

[0126] In addition, this application also provides a microservice communication device. For example... Figure 7 As shown, Figure 7 This is a schematic diagram of the hardware operating environment involved in the embodiments of this application.

[0127] For example, Figure 7 This can be a schematic diagram of the hardware operating environment of a microservice communication device.

[0128] like Figure 7 As shown, the microservice communication device may include a processor 701, a communication interface 702, a memory 703, and a communication bus 704. The processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704. The memory 703 is used to store computer programs. When the processor 701 executes the program stored in the memory 703, it implements the steps of the microservice communication method.

[0129] The communication bus 704 mentioned in the microservice communication device above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 704 can be divided into an address bus, a data bus, and a control bus, etc. For ease of illustration, it is represented by only one thick line in the figure, but this does not indicate that there is only one bus or one type of bus.

[0130] Communication interface 702 is used for communication between the aforementioned microservice communication device and other devices.

[0131] The memory 703 may include random access memory (RMD) or non-volatile memory (NM), such as at least one disk storage device. Optionally, the memory 703 may also be at least one storage device located remotely from the aforementioned processor 701.

[0132] The processor 701 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0133] The specific implementation of the microservice communication device in this application is basically the same as the embodiments of the microservice communication method described above, and will not be repeated here.

[0134] Furthermore, this application also proposes a computer storage medium storing a microservice communication program, which, when executed by a processor, implements the steps of the microservice communication method described above.

[0135] The specific implementation of the computer storage medium in this application is basically the same as the embodiments of the microservice communication method described above, and will not be repeated here.

[0136] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0137] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0138] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0139] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A microservice communication method, characterized in that, The microservice communication method includes the following steps: Obtain the node information of the adjacent microservice layer to be communicated with, and obtain the communication requirements of the adjacent microservice layer; Based on the communication requirements and the node information, the nodes are managed through a preset distributed registration center, and the communication paths between the adjacent microservice layers are determined. The communication paths include direct communication paths and relay communication paths. When the load of the direct communication path reaches a preset threshold, the system automatically switches to the relay communication path. Based on the communication path, a reusable communication connection is established using a lightweight communication protocol and a long connection mechanism, and communication is performed between the adjacent microservice layers based on the reusable communication connection.

2. The microservice communication method as described in claim 1, characterized in that, The step of determining the communication path between adjacent microservice layers based on the communication requirements and the node information includes: Based on the communication requirements and the node information, determine the currently available nodes in the adjacent microservice layer; Based on a preset path selection algorithm and the currently available nodes, a communication path is determined between adjacent microservice layers, wherein the communication path covers all currently available nodes.

3. The microservice communication method as described in claim 2, characterized in that, The adjacent microservice layer includes the previous microservice. The communication path between adjacent microservice layers includes direct communication paths. The step of determining the communication path between adjacent microservice layers based on a preset path selection algorithm and the currently available nodes includes: Based on the preset path selection algorithm and the currently available nodes, a first mapping relationship is established between each node of the upper microservice layer and each node of the lower microservice layer through a distributed registration center, and the direct communication path between the adjacent microservice layers is determined based on the first mapping relationship. The communication protocol used when communicating via the direct communication path includes at least the TCP protocol.

4. The microservice communication method as described in claim 3, characterized in that, If the communication path is a direct communication path, then the step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism includes: Based on the direct communication path, determine the communication node to be communicated in the upper microservice layer, and determine the distribution node to be distributed that has the first mapping relationship with the communication node to be communicated in the lower microservice layer; According to the preset load balancing algorithm, the requests in the nodes to be communicated are evenly distributed to each node to be distributed, and a reusable communication connection is established between the nodes to be communicated and each node to be distributed using a lightweight communication protocol and a long connection mechanism.

5. The microservice communication method as described in claim 2, characterized in that, The adjacent microservice layers include an upper microservice layer and a lower microservice layer, the communication path includes a relay communication path, and the method further includes the step of determining the communication path between the adjacent microservice layers based on a preset path selection algorithm and the currently available nodes. Based on the preset path selection algorithm and the currently available nodes, the routes set in the next microservice layer are used as relays, and based on the relays, a second mapping relationship is determined between each node of the previous microservice layer and each node of the next microservice layer. Based on the second mapping relationship, the relay communication path between the adjacent microservice layers is determined; The communication protocol used when communicating through the relay communication path includes at least the HTTP protocol.

6. The microservice communication method as described in claim 2, characterized in that, The communication path includes a direct communication path. The step of establishing a reusable communication connection based on the communication path using a lightweight communication protocol and a long-connection mechanism includes: Based on the direct communication path, a reusable communication connection is established using a lightweight communication protocol and a long connection mechanism. After the load on the direct communication path reaches a preset threshold, the reusable communication connection is established based on the direct communication path and the relay communication path.

7. A microservice communication system, characterized in that, The microservice communication system includes an input terminal, an intermediate processing microservice layer, and an output terminal: The intermediate processing microservice layer includes at least two microservice layers with sequential processing order and a distributed registry center; The distributed registration center is used to receive node information from different microservice layers and register the node addresses of adjacent microservice layers to be communicated based on the node information, so that the intermediate processing microservice layer can establish direct communication between the adjacent microservice layers. The input terminal and the output terminal can be the same terminal, used to communicate and interact with the intermediate processing microservice layer. The communication protocol between the input end and the output end and the intermediate processing microservice layer includes long connection mechanism and short connection mechanism.

8. A microservice communication device, characterized in that, The microservice communication device includes: The acquisition module is used to acquire node information of the adjacent microservice layer to be communicated with, and to acquire the communication requirements of the adjacent microservice layer. The determination module is used to manage nodes through a preset distributed registration center according to the communication requirements and the node information, and to determine the communication path between adjacent microservice layers. The communication path includes a direct communication path and a relay communication path. When the load of the direct communication path reaches a preset threshold, the module automatically switches to the relay communication path. The communication module is used to establish a reusable communication connection based on the communication path using a lightweight communication protocol and a long connection mechanism, and to communicate between adjacent microservice layers based on the reusable communication connection.

9. A microservice communication device, characterized in that, The device includes: a memory, a processor, and a microservice communication program stored in the memory and executable on the processor, the microservice communication program being configured to implement the steps of the microservice communication method as described in any one of claims 1 to 6.

10. A computer storage medium, characterized in that, The computer storage medium stores a microservice communication program, which, when executed by a processor, implements the steps of the microservice communication method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Micro-service calling method and device, terminal equipment and storage medium

    CN112433863A

  • Load balancing method and device and storage medium

    CN112527510A

  • Tracking method and device for task execution progress based on micro-service architecture

    CN115374175A