Data transmission method and device of distributed system, equipment and medium

By introducing a shared memory timing control area and a persistent buffer into the distributed system, and processing messages asynchronously, the contradiction between data consistency and communication efficiency is resolved, achieving efficient data transmission and rapid fault recovery.

CN121567720APending Publication Date: 2026-02-24ORIENT SECURITIES COMPANY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511937658.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

In distributed systems, existing technologies suffer from limited communication efficiency due to data consistency requirements, making it difficult to meet the needs of high-concurrency and low-latency scenarios.

Method used

By using a timing control area and a persistent buffer in shared memory, messages are processed asynchronously. The timing control area determines the number of the message to be processed, and the message is asynchronously stored in the persistent buffer after processing. This satisfies data consistency requirements while improving system throughput.

Benefits of technology

It improves the communication efficiency of distributed systems, reduces latency, meets the communication needs of high-concurrency and low-latency scenarios, and enables rapid recovery in the event of node failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121567720A_ABST
    Figure CN121567720A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and device of a distributed system, equipment and a medium, and relates to the field of communication. Distributing node memories for nodes of the distributed system in a pre-created shared memory; the node memory comprises a time sequence control area and a persistent buffer area; determining a to-be-processed number of the to-be-processed message based on the time sequence control area; the to-be-processed messages comprise to-be-sent and to-be-received messages; based on the to-be-processed number, executing a corresponding processing operation on the to-be-processed message; after the processing operation is executed, setting a processed state for the to-be-processed message; storing the to-be-processed message to a persistent buffer area; and writing the message with the processing state being the processed state and the message attribute being the persistent attribute in the persistent buffer area into a persistent file so as to ensure the data consistency of the distributed system. According to the method, the shared memory is introduced, message processing and message persistence operation are asynchronously carried out, the system throughput is improved, and delay is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communications, and in particular to a data transmission method, apparatus, device, and medium for a distributed system. Background Technology

[0002] Distributed systems are widely used in business scenarios such as electronic trading, real-time risk control, video transmission, and the Internet of Things. To ensure the reliability of distributed systems in multi-node environments, data consistency is usually required, meaning that the data on all nodes in the system must remain consistent.

[0003] Currently, persistent storage is typically achieved by synchronously writing messages to persistent files when nodes send or receive messages, thus meeting data consistency requirements. However, this approach limits the communication efficiency between nodes to the I / O performance of the underlying storage, resulting in limited throughput and high response latency in distributed systems, making it difficult to meet the communication needs of high-concurrency, low-latency scenarios.

[0004] Therefore, there is an urgent need to provide a data transmission method for distributed systems that can improve communication efficiency while meeting data consistency requirements. Summary of the Invention

[0005] The purpose of this invention is to provide a data transmission method, apparatus, device, and medium for a distributed system, which can improve system throughput and reduce latency while meeting data consistency requirements, thereby improving system communication efficiency.

[0006] To address the aforementioned technical problems, this invention provides a data transmission method for a distributed system, the method comprising: The node memory corresponding to the current node is determined from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed. Based on the timing control area, the processing number of the message to be processed is determined; the message to be processed includes messages to be sent and messages to be received. Based on the pending number, perform the corresponding processing operation on the pending message; and after the processing operation is completed, determine the processing status of the pending message as processed. The message to be processed is stored in the persistent buffer; The target message that meets the preset conditions in the persistent buffer is written to the persistent file; after writing is completed, the target message is removed from the persistent buffer; the preset conditions are that the processing state is the processed state and the message attribute is a persistent attribute that indicates that the message needs to be persisted.

[0007] Optionally, when the message to be processed is a message to be sent, after writing the target message that meets the preset conditions in the persistent buffer to the persistent file, the method further includes: The pending number and the receiving node identifier are used as features of the pending message; the receiving node identifier is the identifier corresponding to the receiving node that receives the pending message. The file write offset of the message to be processed in the persistent file and the message length of the message to be processed are used as the feature values ​​of the message to be processed. The features and feature values ​​are stored as mapping pairs in the timing control area.

[0008] Optionally, the method further includes: Upon receiving a retransmission request, the requesting node identifier and retransmission message number are determined based on the retransmission request; the requesting node identifier is the identifier corresponding to the requesting node that issued the retransmission request. The request node identifier and the retransmission message number are used as target features; Based on the time-series control region, determine whether there is a target feature value corresponding to the target feature; If the target feature value exists, then the retransmission message is read from the persistent file based on the target feature value; and the retransmission message is transmitted to the request node. If the target feature value does not exist, an empty response data packet is generated; the empty response data packet includes at least the retransmission message number.

[0009] Optionally, when the message to be processed is a message to be received, based on the message to be processed number, a corresponding processing operation is performed on the message to be processed, including: Based on the message to be processed, the sending node identifier is determined; the sending node identifier is the identifier corresponding to the sending node that sent the message to be processed. Based on the sending node identifier, the number of the latest received message is read from the designated timing control area, and the next number is used as the expected message number; the designated timing control area is used to store the numbers of messages that the current node has received and that were sent by the sending node; Determine whether the pending number and the expected message number are consistent; If they match, proceed to the step of performing the corresponding processing operation on the message to be processed.

[0010] Optionally, the method further includes: If the pending message number is less than the expected message number, then the pending message is discarded. If the pending number is greater than the expected message number, a retransmission request is generated based on the pending number and the expected message number; the retransmission request is then transmitted to the sending node.

[0011] Optionally, when the pending message number is greater than the expected message number, the method further includes: The messages to be processed are stored in a pre-created temporary message queue; Based on the pending message number and the expected message number, a retransmission request is generated, including: Use the expected message number as the retransmission start number and the number obtained by subtracting one from the pending number as the retransmission end number. A retransmission request containing the retransmission start number and the retransmission end number is generated so that the sending node retransmits each message numbered from the retransmission start number to the retransmission end number.

[0012] Optionally, the method further includes: During the initialization phase of restarting a faulty node, the faulty node identifier corresponding to the faulty node is obtained from the specified configuration file according to the state recovery request. Based on the fault node identifier, determine the persistent buffer corresponding to the fault node; and use the persistent buffer as the persistent buffer to be recovered; Messages in the persistent buffer that meet the preset conditions are taken as messages to be recovered; The message to be recovered is written to the persistent file, and after the writing is completed, the message to be recovered is removed from the recovery persistent buffer.

[0013] This application also provides a data transmission apparatus for a distributed system, the apparatus comprising: The node memory determination module is used to determine the node memory corresponding to the current node from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed. The message number determination module is used to determine the processing number of the message to be processed based on the timing control area; the message to be processed includes messages to be sent and messages to be received by the node; The message processing module is used to perform corresponding processing operations on the message to be processed based on the message number to be processed; and after the processing operation is completed, determine the processing status of the message to be processed as processed. The message storage module is used to store the message to be processed into the persistent buffer; The message persistence module is used to write target messages that meet preset conditions in the persistence buffer to a persistence file; after writing is completed, the target messages are removed from the persistence buffer; the preset conditions are that the processing state is the processed state and the message attribute is a persistence attribute that indicates that the message needs to be persisted.

[0014] This application also provides an apparatus, comprising: Memory, used to store computer programs; A processor, used to implement the data transmission method of any of the above-described distributed systems when executing the computer program.

[0015] This application also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described distributed system data transmission methods.

[0016] In summary, this invention provides a data transmission method, apparatus, device, and medium for a distributed system. Node memory is allocated to nodes of the distributed system within pre-created shared memory; the node memory includes a timing control area and a persistent buffer; based on the timing control area, the processing number of the messages to be processed is determined; the messages to be processed include messages to be sent and messages to be received; based on the processing number, corresponding processing operations are performed on the messages to be processed; after the processing operation is completed, a processed state is set for the messages to be processed; the messages to be processed are stored in the persistent buffer; messages in the persistent buffer with a processed state and persistent attributes are written to a persistent file to ensure data consistency in the distributed system. This application improves system throughput and reduces latency by introducing shared memory and performing message processing and persistence operations asynchronously. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the prior art and embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A first flowchart of a data transmission method for a distributed system provided in this application; Figure 2 A second flowchart of a data transmission method for a distributed system provided in this application; Figure 3 A schematic diagram of the structure of a data transmission device for a distributed system provided in this application; Figure 4This is a schematic diagram of the structure of a device provided in this application. Detailed Implementation

[0019] The core of this invention is to provide a data transmission method, apparatus, device, and medium for a distributed system, which can improve system throughput and reduce latency while meeting data consistency requirements, thereby improving system communication efficiency.

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Please refer to Figure 1 , Figure 1 A first flowchart of a data transmission method for a distributed system provided in this application, the method comprising: S1. Determine the node memory corresponding to the current node from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed.

[0022] In this application, shared memory is pre-created, and corresponding node memory is allocated for each node in the distributed system. Please refer to... Figure 2 , Figure 2 This is a second flowchart illustrating a data transmission method for a distributed system provided in this application. Figure 2 As shown, shared memory is created in advance based on the total number of nodes in the distributed system and the estimated message volume. Using the node's identifier (e.g., node number) as an index, the shared memory dynamically allocates memory to each node. Based on this, the current node can determine its own node memory from the shared memory using its own identifier; subsequently, it can also access the node memory of other nodes based on their identifiers.

[0023] Shared memory technology allows nodes in a distributed system to access the same physical memory region. Each node has its own dedicated memory, and other nodes can access the memory of each node, thus achieving efficient data sharing and laying the foundation for subsequent data transmission.

[0024] Furthermore, each node's memory includes a timing control area and a persistent buffer. Both the timing control area and the persistent buffer are essentially shared memory spaces accessible to all nodes in the distributed system. The timing control area stores the serial numbers of historical messages that the node has processed. This area can be further divided into a sending timing control area and a receiving timing control area; the sending area stores the serial numbers of messages sent by the node, and the receiving area stores the serial numbers of messages received by the node. In both the sending and receiving timing control areas, the message serial numbers are sequentially incrementing to ensure strict order in which messages are sent and received. The persistent buffer stores messages awaiting persistence, which will be explained later.

[0025] S2. Based on the timing control area, determine the processing number of the message to be processed; the message to be processed includes the message to be sent and the message to be received.

[0026] The aforementioned pending messages include messages to be sent and messages to be received; messages to be sent are those that the current node intends to send to other nodes; messages to be received are those that other nodes intend to send to the current node. Both messages to be sent and messages to be received require their processing number to be determined based on the historical message numbers stored in the timing control area, ensuring a strict order of information sent and received by the nodes.

[0027] For example, the maximum number in the sending timing control area is incremented by one to become the pending processing number of the message to be sent; the maximum number in the receiving timing control area is incremented by one to become the pending processing number of the message to be received. Of course, sub-control areas can be further set within the sending timing control area; each sub-control area corresponds to a different receiving node, so as to maintain the message numbers transmitted between the current node and each receiving node independently. For example, when the current node sends a message to a specified receiving node, the maximum number in the sub-control area corresponding to the specified receiving node is incremented by one to become the message number. The receiving timing control area follows the same principle, and will not be elaborated further in this application.

[0028] S3. Based on the pending processing number, perform the corresponding processing operation on the pending message; and after the processing operation is completed, determine the processing status of the pending message as processed.

[0029] One aspect of this application involves performing corresponding processing operations on messages to be processed based on their pending processing numbers. For example, adding the pending processing number to the message header of a message to be sent, and then sending the message to the designated receiving node; and performing consistency verification on messages to be received based on their pending processing numbers, and after successful consistency verification, passing the message from the lower layer to the upper layer application for processing via application interface callbacks or message queues. In summary, the above processing operations can be adaptively adjusted according to the message type of the pending message (whether to be sent or received) and actual needs, and this application does not impose any particular limitations on this.

[0030] After the corresponding operation is completed, the processing status of the message to be processed is set to the processed status so that subsequent persistence operations can be performed.

[0031] S4. Store the messages to be processed in the persistent buffer.

[0032] S5. Write the target message that meets the preset conditions in the persistent buffer to the persistent file; after writing is completed, remove the target message from the persistent buffer; the preset conditions are that the processing status is processed and the message attribute is a persistent attribute that indicates that the message needs to be persisted.

[0033] Another aspect of this application involves storing messages to be processed in a persistent buffer. This storage step does not need to be performed synchronously with the processing operation of the messages to be processed. The persistent buffer may include a persistent queue for sending messages and a persistent queue for receiving messages. Of course, the persistent message queues and the persistent receiving message queues can be configured with read / write attributes to pause new write operations when the queues are full, thus preventing message loss.

[0034] Furthermore, a preset condition is established that the message is in a processed state and has persistent attributes indicating that it needs to be persisted. Messages in the persistence buffer that meet this preset condition are selected as target messages. These target messages are written to the persistence file to achieve message persistence and ensure the consistency of the distributed data system. To avoid duplicate persistence, messages successfully written to the persistence file are removed from the persistence buffer.

[0035] When a message needs to be persisted, it is not written directly to the persistent file. Instead, it is first placed in the message queue of the persistent buffer. The node can then continue with subsequent message sending, receiving, or other processing. The step of writing the file to the persistent file is asynchronous with the steps of sending, receiving, or other processing messages.

[0036] As can be seen, in this application, the message sending and receiving operations of nodes are asynchronous operations with the message persistence operations. Thus, the communication efficiency between nodes is no longer limited by the I / O performance of the underlying storage, thereby improving the throughput of the distributed system, reducing response latency, and meeting the communication needs of high-concurrency, low-latency scenarios.

[0037] Furthermore, it should be noted that the execution entity of the data transmission method for the distributed system provided in this application is the current node. Each node in the distributed system can act as the current node to transmit data with other nodes in the distributed system according to the data transmission method provided in this application, ensuring data consistency.

[0038] In summary, this application provides a data transmission method for a distributed system. Node memory is allocated to nodes in a pre-created shared memory space. The node memory includes a timing control area and a persistent buffer. Based on the timing control area, the processing number of the messages to be processed is determined. The messages to be processed include messages to be sent and messages to be received. Based on the processing number, corresponding processing operations are performed on the messages to be processed. After the processing operation is completed, the processed message is set to a processed state. The messages to be processed are stored in the persistent buffer. Messages in the persistent buffer with a processed state and persistent attributes are written to a persistent file to ensure data consistency in the distributed system. This application improves system throughput and reduces latency by introducing shared memory and performing message processing and persistence operations asynchronously.

[0039] Based on the above embodiments: As an optional embodiment, when the message to be processed is a message to be sent, after writing the target message that meets the preset conditions in the persistent buffer to the persistent file, the method further includes: The pending number and the receiving node identifier are used as the characteristics of the pending message; the receiving node identifier is the identifier corresponding to the receiving node that receives the pending message. The file write offset of the message to be processed in the persistent file, and the message length of the message to be processed are used as the feature values ​​of the message to be processed. Features and feature values ​​are stored as mapping pairs in the time-series control area.

[0040] In this embodiment, when the message to be processed is a message to be sent, after writing the target message that meets the preset conditions in the persistent buffer into the persistent file, the file write offset and message length of the target message are also recorded in the timing control area so that if the receiving node fails to receive the message, the message can be reread from the persistent file and resent to ensure the reliability of data transmission.

[0041] To achieve the above objectives, such as Figure 2 As shown, this embodiment uses the message number to be processed and the receiving node identifier as features of the message to be processed. The file write offset of the message to be processed in the persistent file and the message length are used as feature values ​​of the message to be processed. The file write offset indicates the starting position of the message to be processed within the persistent file when it is written, so that the message can be read subsequently based on the file write offset and the message length.

[0042] Features and feature values ​​are stored as mapping pairs in the timing control area. This allows for subsequent lookup of the corresponding feature value from the timing control area based on the feature with the retransmission request, i.e., finding the file write offset corresponding to the message requiring retransmission. The retransmission process is explained in detail below.

[0043] As an optional embodiment, the method further includes: Upon receiving a retransmission request, the requesting node identifier and retransmission message number are determined based on the retransmission request; the requesting node identifier is the identifier corresponding to the requesting node that issued the retransmission request. Use the request node identifier and retransmission message number as target characteristics; Based on the temporal control region, determine whether there is a target feature value corresponding to the target feature; If a target feature value exists, the retransmission message is read from the persistent file based on the target feature value; and the retransmission message is transmitted to the requesting node. If the target feature value does not exist, an empty response data packet is generated; the empty response data packet must include at least the retransmission message number.

[0044] When generating a retransmission request, the requesting node adds its own identifier and the retransmission message number to the request. The retransmission message number can be the number of all messages that need to be retransmitted. Considering the sequential nature of message numbers, the retransmission message number can also be the number corresponding to the first message that needs to be retransmitted, and the number corresponding to the last message that needs to be retransmitted. The setting can be adjusted according to actual needs.

[0045] The target feature is obtained by combining the request node identifier and the retransmission message number. The existence of a target feature value corresponding to the target feature is then determined from the timing control area of ​​the current node. Therefore, in this embodiment, when a message needs to be retransmitted, there is no need for inefficient full message traversal. Instead, the corresponding target feature value is directly located in the timing control area based on the target feature, and the retransmission message is accurately located based on the target feature value, thus improving retransmission efficiency.

[0046] Specifically, if a target feature value exists, the starting storage position of the retransmitted message in the persistent file is located based on the target file write offset; the reading range is determined based on the message length to achieve the purpose of reading the retransmitted message; and the retransmitted message is transmitted to the requesting node. This embodiment does not impose any special limitations on the process of retransmitting messages at the current node.

[0047] If no target feature value exists, the message is considered non-persistent. In this case, an empty response packet is generated directly to avoid the requesting node from waiting indefinitely; the empty response packet must include at least the retransmission message number. If multiple consecutive empty packets requiring a response exist, they are merged to generate a merged response packet containing the retransmission start message number and the retransmission end message number, thereby improving retransmission efficiency.

[0048] like Figure 2 As shown, this application also performs consistency verification on the message label in response to the message reception request of the current node. The consistency verification process for the message to be received is described in detail below.

[0049] As an optional embodiment, when the message to be processed is a message to be received, based on the message's processing number, a corresponding processing operation is performed on the message to be processed, including: Based on the message to be processed, determine the sending node identifier; the sending node identifier is the identifier corresponding to the sending node that sent the message to be processed. Based on the sending node identifier, the latest received message number is read from the designated timing control area, and the next number is used as the expected message number; the designated timing control area is used to store the message numbers that the current node has received and that were sent by the sending node. Determine if the pending message number and the expected message number are consistent; If they match, proceed to the step of performing the corresponding processing operation on the message to be processed.

[0050] In this embodiment, consistency verification of the received message is required. Specifically, since the sending node typically adds its own identifier to the message header when generating the message to be processed, the sending node identifier can be determined based on the message to be processed.

[0051] Next, based on the sending node identifier, the latest received message number is read from the designated timing control area, and the next number after that is used as the expected message number. Here, the designated control area refers to the region within the timing control area corresponding to the current node, used to store the message numbers that the current node has received and that were sent by the sending node. That is, the current node's timing control area is further divided into timing sub-control areas corresponding to other nodes in the distributed system, in order to perform consistency verification of messages transmitted between the two nodes.

[0052] Next, it is determined whether the message number to be processed and the expected message number are consistent. If they are consistent, the corresponding processing operation is performed on the message to be processed. For example, the message to be processed is sent to the upper-layer application. It can be seen that in this embodiment, the message is only processed when the received message number is exactly the same as the expected message number. This mechanism eliminates message processing errors caused by network latency, out-of-order delivery, etc., ensuring that each node processes messages from the same sender in exactly the same order, further guaranteeing data consistency in the distributed system.

[0053] When the pending message number does not match the expected message number, an anomaly can be identified (e.g., message duplication or message loss). Therefore, as an optional embodiment, the method further includes: If the pending message number is less than the expected message number, then discard the pending message; If the pending message number is greater than the expected message number, a retransmission request is generated based on the pending message number and the expected message number; the retransmission request is then transmitted to the sending node.

[0054] If the pending message number is less than the expected message number, it means that the pending message is a duplicate transmission and can be discarded.

[0055] When the pending message number is greater than the expected message number, it indicates that a message has been lost. For example, if the expected message number is 10 and the pending message number is 13, it means that the current node has not received messages numbered 10, 11, and 12 from the sending node. In this case, a retransmission request is generated based on the pending message number and the expected message number, and the retransmission request is transmitted to the sending node. As you can see, the retransmission request is very explicit, avoiding unnecessary resource waste caused by retransmitting messages. The process of determining the retransmission request is explained in detail below.

[0056] As an optional embodiment, when the number to be processed is greater than the expected message number, the method further includes: Store the messages to be processed in a pre-created temporary message queue; Based on the pending message number and the expected message number, generate a retransmission request, including: Use the expected message number as the start number of retransmission and the number obtained by subtracting one from the pending number as the end number of retransmission. Generate a retransmission request containing a retransmission start number and a retransmission end number so that the sending node can retransmit each message numbered from the retransmission start number to the retransmission end number.

[0057] To further reduce the communication resources consumed by retransmitting messages, this application stores the pending messages received by the current node in a temporary message queue, so that the sending node does not need to retransmit the pending messages.

[0058] Furthermore, this embodiment eliminates the need to generate a separate retransmission request for each lost message. Instead, it uses the expected message number as the retransmission start number and the number obtained by subtracting one from the pending message number as the retransmission end number. Then, a retransmission request containing both the start and end numbers is generated, clearly specifying the range of messages requiring retransmission. The sending node simply retransmits all messages with message numbers from the start to the end number, avoiding unnecessary full retransmissions and significantly improving retransmission efficiency.

[0059] like Figure 2 As shown, this application also responds to a node's message recovery request by determining the persistent buffer that needs to be recovered, and continuing to perform persistence operations on messages that meet preset conditions. The message recovery process is described below.

[0060] As an optional embodiment, the method further includes: During the initialization phase of restarting a faulty node, the faulty node identifier corresponding to the faulty node is obtained from the specified configuration file based on the state recovery request. Based on the fault node identifier, determine the persistent buffer corresponding to the fault node; and use the persistent buffer as the persistent buffer to be recovered; Messages that meet the preset conditions in the persistent buffer to be recovered are taken as messages to be recovered; Write the message to be recovered to the persistent file, and remove the message from the recovery persistent buffer after the writing is complete.

[0061] In the current approach, when a distributed system fails, a full data load from persistent files is required to restore system consistency, and the recovery time is positively correlated with the amount of data. For high-concurrency systems, performing a full recovery may result in excessively long service interruptions, even exceeding acceptable business requirements, making it difficult to meet the stringent service continuity requirements of the business.

[0062] In this application, the persistent buffer is located in shared memory, so the content stored in the persistent buffer will not be lost due to restart or failure. Based on this, this embodiment can directly read non-persistent messages from the persistent buffer and write these messages to the persistent file, without needing to load the entire file.

[0063] Specifically, in this embodiment, when a process in the distributed system unexpectedly restarts due to a fault, the faulty node generates a state recovery request during the restart and recovery process. Based on the state recovery request, the faulty node identifier corresponding to the faulty node is obtained from a specified configuration file so that the unfinished persistence operations on the faulty node's persistent buffer can continue. As mentioned earlier, there is a one-to-one correspondence between nodes and node memory; the corresponding node memory can be accessed based on the node identifier. Therefore, the persistent buffer to be recovered corresponding to the faulty node can be quickly determined based on the faulty node identifier.

[0064] Next, the messages in the persistent buffer to be recovered are read, and messages that meet the preset conditions (processing status is "processed" and message attributes are persistent attributes that indicate the message needs to be persisted) are designated as messages to be recovered. Then, the messages to be recovered are written to the persistent file, and after writing is complete, the messages to be recovered are removed from the persistent buffer.

[0065] Thus, this application quickly restores the node to its pre-failure state and switches it to normal operation, achieving rapid recovery in abnormal scenarios without requiring full data loading, minimizing the impact on business operations.

[0066] In summary, this application achieves asynchronous processing of message persistence operations by introducing a timing control area and a persistent buffer within shared memory, significantly reducing communication latency caused by disk I / O waits and improving system throughput. Furthermore, it optimizes the strong ordering and consistency of messages transmitted between nodes. Merging retransmission requests for non-persistent messages effectively reduces redundant interactions and improves retransmission efficiency. Moreover, leveraging the persistence characteristics of shared memory, it enables rapid reconstruction after a node's abnormal restart, greatly enhancing the availability and fault recovery efficiency of the distributed system.

[0067] Please refer to Figure 3 , Figure 3 This application provides a schematic diagram of the structure of a data transmission device for a distributed system, the device comprising: The node memory determination module 301 is used to determine the node memory corresponding to the current node from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed. The message number determination module 302 is used to determine the processing number of the message to be processed based on the timing control area; the message to be processed includes messages to be sent and messages to be received by the node. The message processing module 303 is used to perform corresponding processing operations on the message to be processed based on the message number to be processed; and after the processing operation is completed, it determines the processing status of the message to be processed as processed. Message storage module 304 is used to store messages to be processed into a persistent buffer; The message persistence module 305 is used to write target messages that meet preset conditions in the persistence buffer to a persistence file; after writing is completed, the target messages are removed from the persistence buffer; the preset conditions are that the processing status is processed and the message attributes are persistent attributes that indicate that the message needs to be persisted.

[0068] For a detailed description of the data transmission device for the distributed system provided in this application, please refer to the embodiments of the data transmission method for the distributed system described above; further details will not be repeated here.

[0069] Based on the above embodiments: As an optional embodiment, when the message to be processed is a message to be sent, the apparatus further includes: The feature determination module is used to write the target message that meets the preset conditions in the persistent buffer to the persistent file, and then use the pending number and the receiving node identifier as the features of the pending message; the receiving node identifier is the identifier corresponding to the receiving node that receives the pending message. The feature value determination module is used to take the file write offset of the message to be processed in the persistent file and the message length of the message to be processed as the feature values ​​of the message to be processed. The mapping pair building module is used to store features and feature values ​​as mapping pairs in the time-series control area.

[0070] As an optional embodiment, the device further includes: The retransmission information generation module is used to determine the requesting node identifier and retransmission message number based on the retransmission request when a retransmission request is received; the requesting node identifier is the identifier corresponding to the requesting node that issued the retransmission request. The target feature determination module is used to use the request node identifier and retransmission message number as target features; The target feature value determination module is used to determine whether a target feature value corresponding to the target feature exists based on the timing control area; if a target feature value exists, the retransmission module is triggered; if no target feature value exists, the response module is triggered. The retransmission module is used to read retransmission messages from the persistent file based on the target feature value and transmit the retransmission messages to the requesting node. The empty response packet generation module is used to generate empty response data packets; the empty response data packet includes at least the retransmission message number.

[0071] As an optional embodiment, when the message to be processed is a message to be received, the message processing module 303 includes: The sending identifier determination module is used to determine the sending node identifier based on the message to be processed; the sending node identifier is the identifier corresponding to the sending node that sent the message to be processed. The expected message number determination module is used to read the number of the latest received message from the specified timing control area based on the sending node identifier, and use the next number as the expected message number; the specified timing control area is used to store the numbers of messages that the current node has received and that have been sent by the sending node. The verification module is used to determine whether the pending message number and the expected message number are consistent; if they are consistent, the message processing submodule is triggered; if the pending message number is less than the expected message number, the message discarding module is triggered; if the pending message number is greater than the expected message number, the retransmission processing module is triggered. The message processing submodule is used to perform corresponding processing operations on the messages to be processed; The message discarding module is used to discard pending messages; The retransmission processing module is used to generate a retransmission request based on the pending message number and the expected message number; and to transmit the retransmission request to the sending node.

[0072] As an optional embodiment, when the number to be processed is greater than the expected message number, the device further includes: The temporary storage module is used to store messages to be processed in a pre-created temporary message queue; The retransmission processing module includes: The retransmission number determination module is used to take the expected message number as the retransmission start number and the number obtained by subtracting one from the number to be processed as the retransmission end number. The retransmission processing submodule is used to generate a retransmission request containing a retransmission start number and a retransmission end number, and transmit the retransmission request to the sending node so that the sending node can retransmit each message with message number from the retransmission start number to the retransmission end number.

[0073] As an optional embodiment, the device further includes: The fault node identifier determination module is used to obtain the fault node identifier corresponding to the fault node from the specified configuration file based on the status recovery request during the initialization phase of the fault node restart. The module for determining the buffer to be recovered is used to determine the persistent buffer corresponding to the faulty node based on the faulty node identifier, and to use the persistent buffer as the persistent buffer to be recovered. The message to be recovered module is used to identify messages in the persistent buffer that meet preset conditions as messages to be recovered. The recovery module is used to write the messages to be recovered to a persistent file and remove the messages to be recovered from the recovery persistence buffer after the writing is complete.

[0074] Please refer to Figure 4 , Figure 4 A schematic diagram of a device provided in this application, the device comprising: Memory 401 is used to store computer programs; Processor 402 is used to implement the steps of any of the above-mentioned distributed system data transmission methods when executing computer programs.

[0075] For a detailed description of the device provided in this application, please refer to the embodiments of the data transmission method of the distributed system described above; this application will not repeat the details here.

[0076] This application also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described distributed system data transmission methods.

[0077] For a detailed description of the storage medium provided in this application, please refer to the embodiments of the data transmission method of the distributed system described above; this application will not repeat the details here.

[0078] The various embodiments described in this specification are presented in a progressive manner, with each embodiment focusing on its differences from other embodiments. It should also be noted that in this specification, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, article, or apparatus 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, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, article, or apparatus that includes said element.

[0079] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data transmission method for a distributed system, characterized in that, The method includes: The node memory corresponding to the current node is determined from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed. Based on the timing control area, the processing number of the message to be processed is determined; the message to be processed includes messages to be sent and messages to be received. Based on the pending number, perform the corresponding processing operation on the pending message; and after the processing operation is completed, determine the processing status of the pending message as processed. The message to be processed is stored in the persistent buffer; The target message that meets the preset conditions in the persistent buffer is written to the persistent file; after writing is completed, the target message is removed from the persistent buffer; the preset conditions are that the processing state is the processed state and the message attribute is a persistent attribute that indicates that the message needs to be persisted.

2. The data transmission method for a distributed system as described in claim 1, characterized in that, When the message to be processed is a message to be sent, after writing the target message that meets the preset conditions in the persistent buffer to the persistent file, the process further includes: The pending number and the receiving node identifier are used as features of the pending message; the receiving node identifier is the identifier corresponding to the receiving node that receives the pending message. The file write offset of the message to be processed in the persistent file and the message length of the message to be processed are used as the feature values ​​of the message to be processed. The features and feature values ​​are stored as mapping pairs in the timing control area.

3. The data transmission method for a distributed system as described in claim 2, characterized in that, The method further includes: Upon receiving a retransmission request, the requesting node identifier and retransmission message number are determined based on the retransmission request; the requesting node identifier is the identifier corresponding to the requesting node that issued the retransmission request. The request node identifier and the retransmission message number are used as target features; Based on the time-series control region, determine whether there is a target feature value corresponding to the target feature; If the target feature value exists, then the retransmission message is read from the persistent file based on the target feature value; and the retransmission message is transmitted to the request node. If the target feature value does not exist, an empty response data packet is generated; the empty response data packet includes at least the retransmission message number.

4. The data transmission method for a distributed system as described in claim 1, characterized in that, When the message to be processed is a message to be received, based on the message to be processed number, the corresponding processing operation is performed on the message to be processed, including: Based on the message to be processed, the sending node identifier is determined; the sending node identifier is the identifier corresponding to the sending node that sent the message to be processed. Based on the sending node identifier, the number of the latest received message is read from the designated timing control area, and the next number is used as the expected message number; the designated timing control area is used to store the numbers of messages that the current node has received and that were sent by the sending node; Determine whether the pending number and the expected message number are consistent; If they match, proceed to the step of performing the corresponding processing operation on the message to be processed.

5. The data transmission method for a distributed system as described in claim 4, characterized in that, The method further includes: If the pending message number is less than the expected message number, then the pending message is discarded. If the pending number is greater than the expected message number, a retransmission request is generated based on the pending number and the expected message number; the retransmission request is then transmitted to the sending node.

6. The data transmission method for a distributed system as described in claim 5, characterized in that, When the pending message number is greater than the expected message number, the method further includes: The messages to be processed are stored in a pre-created temporary message queue; Based on the pending message number and the expected message number, a retransmission request is generated, including: Use the expected message number as the retransmission start number and the number obtained by subtracting one from the pending number as the retransmission end number. A retransmission request containing the retransmission start number and the retransmission end number is generated so that the sending node retransmits each message numbered from the retransmission start number to the retransmission end number.

7. The data transmission method for a distributed system as described in claim 1, characterized in that, The method further includes: During the initialization phase of restarting a faulty node, the faulty node identifier corresponding to the faulty node is obtained from the specified configuration file according to the state recovery request. Based on the fault node identifier, determine the persistent buffer corresponding to the fault node; and use the persistent buffer as the persistent buffer to be recovered; Messages in the persistent buffer that meet the preset conditions are taken as messages to be recovered; The message to be recovered is written to the persistent file, and after the writing is completed, the message to be recovered is removed from the recovery persistent buffer.

8. A data transmission device for a distributed system, characterized in that, The device includes: The node memory determination module is used to determine the node memory corresponding to the current node from the pre-created shared memory; the node memory includes a timing control area and a persistent buffer; the timing control area is used to store the numbers of historical messages that the node has processed. The message number determination module is used to determine the processing number of the message to be processed based on the timing control area; the message to be processed includes messages to be sent and messages to be received by the node; The message processing module is used to perform corresponding processing operations on the message to be processed based on the message number to be processed; and after the processing operation is completed, determine the processing status of the message to be processed as processed. The message storage module is used to store the message to be processed into the persistent buffer; The message persistence module is used to write target messages that meet preset conditions in the persistence buffer to a persistence file; after writing is completed, the target messages are removed from the persistence buffer; the preset conditions are that the processing state is the processed state and the message attribute is a persistence attribute that indicates that the message needs to be persisted.

9. A device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data transmission method for a distributed system as described in any one of claims 1 to 7 when executing the computer program.

10. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the data transmission method for a distributed system as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Message middleware receiver abnormity processing method, server and storage medium

    CN109710421A

  • Message queue processing method, medium, equipment and system

    CN113505012A

  • Inter-process communication method based on shared memory

    CN118606069A