A communication method and system for distributed services

By adopting a dual message queue mechanism in distributed services, selecting local or distributed message queues to send messages according to the target address, the problem of low communication efficiency of distributed services is solved and efficient process execution and decoupling is achieved.

CN115801776BActive Publication Date: 2025-08-15TUYOO GAMES +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211374795.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-04
Publication Date
2025-08-15
Estimated Expiration
2042-11-04

AI Technical Summary

Technical Problem

In the prior art, the communication between distributed services is inefficient, and a centrally deployed message middleware platform is required, resulting in low inter-process execution efficiency.

Method used

The dual message queue mechanism is adopted to identify the target address within the service process. If it is local, it will be sent to the local message queue. If it is remote, it will be sent to the distributed system message queue server to avoid network protocol packet and unpacking operations, and to realize local message consumption only requires memory copy operations.

Benefits of technology

It improves process execution efficiency, realizes decoupling between distributed services, and reduces strong business coupling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115801776B_ABST
    Figure CN115801776B_ABST
Patent Text Reader

Abstract

The present application provides a communication method and system for distributed services, comprising: a service process running on a distributed node generates a communication message; obtaining a target address for the communication message within the service process; and the service process sending the communication message to a message queue server or a message queue on the current node based on the target address. This approach enables local message consumption to require only simple operations in local memory, eliminating the need for network protocol encapsulation and unpacking, thereby improving process execution efficiency. The use of dual message queues also decouples distributed services, eliminating the need for strong business coupling between service processes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a communication method and system for distributed services, a computing device, and a computer-readable storage medium. Background Art

[0002] In existing distributed services, service processes are distributed across multiple servers. The implementation of business logic typically requires the coordination of these processes, which in turn requires the collaboration of these processes through message communication. Most existing technologies utilize a centralized messaging middleware platform to implement inter-process communication. This requires all messages to be sent over the network to the messaging middleware platform to enable message publishing and consumption, resulting in low inter-process execution efficiency. Summary of the Invention

[0003] In view of this, embodiments of the present application provide a communication method and system for distributed services, a computing device, and a computer-readable storage medium to address the technical deficiencies in the prior art.

[0004] According to a first aspect of an embodiment of the present application, a communication method for a distributed service is provided, including:

[0005] The service processes running on distributed nodes generate communication messages;

[0006] Obtaining a destination address of the communication message within the service process;

[0007] The service process sends the communication message to a message queue server or to a local message queue service on the current node according to the target address.

[0008] According to a second aspect of an embodiment of the present application, a communication system for distributed services is provided, including:

[0009] Multiple distributed nodes and at least one message queue server;

[0010] Wherein, at least one service process runs on each distributed node, and the service process generates communication messages;

[0011] The service process obtains the target address of the communication message;

[0012] The service process further includes a routing module, which sends the communication message to a message queue server or to a local message queue service on a current node according to a target address.

[0013] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the communication method for the distributed service when executing the instructions.

[0014] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the communication method of the distributed service are implemented.

[0015] In an embodiment of the present application, a communication method between distributed service processes is implemented by means of dual message queues. The target address of the message generated by the service process is identified in each service process on the distributed node. If the target address is a local service process, the message is routed to a local message queue implemented based on shared memory. If the target address is a remote service process, the message is routed to a message queue server on the distributed system. In this way, the consumption of local messages only requires a memory copy operation, and there is no need for packaging and unpacking under the network protocol, thereby improving the execution efficiency of the process. At the same time, the use of dual message queues also realizes the decoupling between distributed services, and there is no need for strong business coupling between the service processes. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;

[0017] Figure 2 This is a flow chart of a communication method for a distributed service provided in an embodiment of the present application;

[0018] Figure 3 This is another flow chart of a communication method for a distributed service provided by an embodiment of the present application;

[0019] Figure 4 This is a structural diagram of a communication system for a distributed service provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The following description sets forth many specific details to facilitate a thorough understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present application. Therefore, the present application is not limited to the specific implementations disclosed below.

[0021] The terms used in one or more embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of the present application. The singular forms "a", "the" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0022] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of one or more embodiments of the present application, first may also be referred to as second, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determining."

[0023] In this application, a communication method and system for distributed services, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0024] Figure 1 1 shows a block diagram of a computing device 100 according to an embodiment of the present application. Components of the computing device 100 include, but are not limited to, a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and a database 150 is used to store data.

[0025] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)), whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0026] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 1The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0027] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.

[0028] Next, a communication method for distributed services provided by an embodiment of the present application is described. Figure 2 , Figure 2 A flowchart of a communication method for a distributed service provided according to an embodiment of the present application is shown. Specifically, this embodiment provides a method step for generating a communication message, including steps 202 to 206.

[0029] Step 202: The service process running on the distributed node generates a communication message.

[0030] In a communication method for a distributed service provided in an embodiment of the present application, multiple distributed nodes are included, and each distributed node includes at least one service process. In the process of implementing business logic, the service process generates a communication message, which is used to notify other service processes to participate in completing the business logic.

[0031] Step 204: Obtain the target address of the communication message within the service process.

[0032] In this step, after the service process on the distributed node generates a communication message, the target address of the communication message is further obtained within the service process.

[0033] Furthermore, the target address includes an identifier of the target service process; in various embodiments of the present application, the service process on each node has a unique identifier in the distributed system, and the unique identifier includes the network address and machine identifier of the service process.

[0034] Step 206: The service process sends the communication message to the message queue server or to the local message queue service on the current node according to the target address.

[0035] In this step, the service process that generates the communication message further resolves the target address;

[0036] Specifically, the target address is resolved through routing within the service process. If the target address is a local address, the communication message is sent to the local message queue service on the current node.

[0037] Furthermore, the local message queue service on the current node is a message queue service created in the shared memory of the current node.

[0038] Furthermore, in the local message queue service, a message queue is created for each service process, and the service process sends the communication message generated by it to the message queue corresponding to the service process in the local message queue.

[0039] If the destination address is a non-local address, the communication message is sent to a message queue server in the distributed system.

[0040] Specifically, the target address of the communication message includes the identifier of the target service process, and the communication message is allocated to the corresponding message queue in the message queue server according to the above identifier information.

[0041] In another embodiment of the present application, a method for consuming communication messages in a communication method of a distributed service is provided, such as Figure 3 As shown, the method includes steps 302 to 304:

[0042] Step 302: The service process running on the distributed node monitors the message queue of the local message queue service and the message queue server at the same time;

[0043] In a feasible implementation, the message queue server includes but is not limited to a message queue server implemented by a message middleware such as Redis, Kafka, RabbitMQ, etc. When the service process on the distributed node monitors the message queue in the message queue server, it adopts a monitoring method suitable for the selected message middleware.

[0044] In another feasible implementation, the service process on the distributed node monitors the message queue in the local message queue service. Specifically, the address block of the monitored message queue in the shared memory of the current node is obtained according to a preset rule.

[0045] Step 304: When the service process monitors the target message in the message queue, it directly consumes the target message.

[0046] Specifically, when the service process monitors the target message in the message queue, it obtains the message and directly executes the business logic according to the message.

[0047] The following is combined with Figure 4 The above-mentioned embodiment will be described in detail.

[0048] In such Figure 4 The communication system of a distributed service shown includes multiple distributed nodes and at least one message queue server.

[0049] exist Figure 4 In a distributed service communication system, at least one service process 1 is running on node 1; the service process 1 is one of the processes used to complete a specified business logic, such as completing a battle in a game.

[0050] Specifically, when service process 1 executes the specified business logic, it generates a communication message A. Further, the target address of communication message A is parsed in service process 1. When the target address is local to node 1, such as Figure 4 Service process n in node 1 sends communication message A to the local message queue of node 1 through routing. This message queue is created in the shared memory of node 1. When the target address is not local to node 1, that is, when the target address is the address of another node in the distributed system, in this specific embodiment, assuming that the target address of communication message A is service process 1 on node 2, communication message A is sent to the corresponding queue of the message queue server through routing within service process 1.

[0051] exist Figure 4 In the distributed service communication system, node 2 also runs at least one service process 1'; the service process 1' is one of the processes used to complete the specified business logic. The service process 1' monitors the specified queue of the message queue server and the local message queue of node 2 at the same time. When a new message appears in the above message queue, the service process 1' directly obtains the message for consumption. Assuming that the service process 1', as a remote target service process, monitors the communication message A sent by the above service process 1 to the message queue server, it obtains the communication message A and consumes the message. Assuming that the service process 1' monitors the communication message B in the local message queue of node 2, it obtains the communication message B from the local message queue and consumes the message.

[0052] Those skilled in the art should be aware that in the above-mentioned communication method and system for distributed services, the service processes on all nodes have the above-mentioned function of implementing communication between service processes, which will not be described in detail here.

[0053] In response to the efficiency problems caused by the centralized deployment method adopted in the communication between distributed services in the prior art, in the above-mentioned embodiment of the present application, a communication method between distributed service processes is implemented through a dual message queue method. The target address of the message generated by the service process is identified in each service process. If the target address is a local service process, the message is routed to the local message queue implemented based on shared memory. If the target address is a remote service process, the message is routed to the message queue server on the distributed system. In this way, the consumption of local messages only requires a memory copy operation, and there is no need for packaging and unpacking under the network protocol, thereby improving the execution efficiency of the process. At the same time, the use of dual message queues also realizes the decoupling between distributed services, and there is no need for strong business coupling between the service processes.

[0054] Corresponding to the above method embodiment, the present application also provides an embodiment of a communication system for distributed services, the system comprising:

[0055] Multiple distributed nodes and at least one message queue server;

[0056] Wherein, at least one service process runs on each distributed node, and the service process generates communication messages;

[0057] The service process obtains the target address of the communication message;

[0058] The service process further includes a routing module, which sends the communication message to a message queue server or to a message queue on a current node according to a target address.

[0059] The above is a schematic diagram of a communication system for a distributed service according to this embodiment. It should be noted that the technical solution of this system and the technical solution of the communication method for a distributed service described above are based on the same concept. For details not described in detail in the technical solution of this system, please refer to the description of the technical solution of the communication method for a distributed service described above.

[0060] In one embodiment of the present application, a computing device is further provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the communication method for a distributed service when executing the instructions.

[0061] The above is a schematic diagram of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the aforementioned distributed service communication method are based on the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the aforementioned distributed service communication method.

[0062] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the communication method for distributed services as described above.

[0063] The above is a schematic diagram of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium is based on the same concept as the technical solution of the aforementioned distributed service communication method. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the aforementioned distributed service communication method.

[0064] The foregoing description describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0065] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or system capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0066] It should be noted that for the aforementioned method embodiments, for ease of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.

[0067] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0068] The preferred embodiments of the present application disclosed above are intended only to help illustrate the present application. The optional embodiments do not describe all details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of this application. This application selects and describes these embodiments in detail in order to better explain the principles and practical applications of this application, so that those skilled in the art can better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.

Claims

1. A communication method for distributed services, characterized in that: include: The service processes running on distributed nodes generate communication messages; Obtaining a destination address of the communication message within the service process; The target address includes an identifier of a target service process; The service process sends the communication message to the message queue server or to the local message queue service on the current node according to the target address; The service process monitors the message queue on the message queue server and the local message queue service on the current node at the same time; When the service process monitors the target message, it directly consumes the target message; When the service process monitors the local message queue service, it obtains the address block of the monitored message queue in the shared memory of the current node according to the preset rules; The service process has a unique identifier in the distributed system, and the identifier includes the network address and machine identifier of the service process.

2. The method according to claim 1, wherein Sending the communication message to a message queue server or to a local message queue service on the current node according to the target address includes: Resolving the target address by routing within the service process, and if the target address is a local address, sending the communication message to the local message queue service on the current node; If the destination address is a non-local address, the communication message is sent to a message queue server.

3. The method according to claim 2, wherein: The message queue on the current node is a message queue created in the shared memory of the current node.

4. A communication system for distributed services, characterized in that: include: Multiple distributed nodes and at least one message queue server; Wherein, at least one service process runs on each distributed node, and the service process generates communication messages; The service process obtains the target address of the communication message; the target address includes an identifier of the target service process; The service process further includes a routing module, which sends the communication message to a message queue server or to a local message queue service on the current node according to the target address; The service process monitors the message queue on the message queue server and the local message queue service on the current node at the same time; when the service process monitors the target message, it directly consumes the target message; When the service process monitors the local message queue service, it obtains the address block of the monitored message queue in the shared memory of the current node according to the preset rules; The service process has a unique identifier in the distributed system, and the identifier includes the network address and machine identifier of the service process.

5. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein: When the processor executes the instructions, the steps of the method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Communication method, system and apparatus

    CN108712332A

  • Spacecraft-oriented high-resolution distributed system software architecture

    CN115002189A

  • Message notification method and device, medium and equipment

    CN115185705A