A message broadcasting method, device and storage medium in a cluster
By configuring the cluster topology for each node in the cluster, messages are relayed in the cluster, which solves the problem of excessive message broadcast load on a single node and achieves good scalability and efficient broadcast of the cluster.
Patent Information
- Application Number
- CN202210103003.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-01-27
AI Technical Summary
In a cluster, when the node size increases, the message broadcast load of a single node is too large, which affects performance and limits the scalability of the cluster.
Configure a cluster topology with itself as the root node for each node in the cluster, so that messages no longer rely entirely on the source node for broadcast, but are broadcast relayed through many nodes in the cluster according to the cluster topology corresponding to the source node. Share the message broadcast load.
It effectively alleviates the message propagation load of a single node, supports better scalability of the cluster, avoids repeated broadcast of messages, and improves broadcast efficiency.
Smart Images

Figure CN114490129B
Abstract
Description
Technical Field
[0001] The present application relates to the field of network technology, and in particular to a message broadcasting method, device and storage medium in a cluster. Background Art
[0002] In a cluster, when a message must be propagated to all nodes, it is usually necessary to send it to all nodes by broadcasting to ensure that each node can receive the message.
[0003] At present, the conventional broadcast scheme is that a single node sends messages to other nodes in the cluster. Under this broadcast scheme, when the node scale of the cluster gradually increases, this single node needs to send messages to more nodes, and its message transmission pressure will continue to increase. The message transmission work will occupy a large amount of processing resources on the single node, affecting the performance of the single node, and ultimately limiting the node scale of the cluster. Summary of the invention
[0004] Multiple aspects of the present application provide a message broadcasting method, device and storage medium in a cluster, so as to reduce the impact of message broadcasting load on a single node caused by cluster expansion.
[0005] The present application embodiment provides a message broadcast method in a cluster, which is applicable to a target node in the cluster, and the method includes:
[0006] Receive messages to be broadcast;
[0007] Determine a cluster topology structure corresponding to a source node to which the message belongs, wherein each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node;
[0008] In the cluster topology corresponding to the source node, determining the child node associated with the target node itself;
[0009] The message is propagated to the child node, so that the child node continues to propagate the message according to the cluster topology structure corresponding to the source node, until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
[0010] The embodiment of the present application also provides a node, including a memory, a processor, and a communication component;
[0011] The memory is used to store one or more computer instructions;
[0012] The processor is coupled to the memory and the communication component and is configured to execute the one or more computer instructions for:
[0013] receiving a message to be broadcasted via the communication component;
[0014] Determine a cluster topology structure corresponding to a source node to which the message belongs, wherein each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node;
[0015] In the cluster topology corresponding to the source node, determining the child node associated with the target node itself;
[0016] The message is propagated to the child node through the communication component, so that the child node continues to propagate the message according to the cluster topology structure corresponding to the source node until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
[0017] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the aforementioned message broadcasting method in the cluster.
[0018] In the embodiment of the present application, each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as the root node. Based on this, for any node in the cluster, after receiving the message to be broadcast, it can determine the cluster topology structure corresponding to the source node to which the message belongs; in the cluster topology structure corresponding to the source node, determine the child node associated with the target node itself; and propagate the message to the child node. In this way, for a message, it is no longer completely dependent on the source node to which it belongs for broadcasting, but many nodes in the cluster relay broadcasting according to the cluster topology structure corresponding to the source node to share the message broadcast load, which ensures that the message broadcast load of a single node will not increase excessively due to the expansion of the cluster scale, and thus can support better scalability of the cluster. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram of a flow chart of a message broadcasting method in a cluster provided by an exemplary embodiment of the present application;
[0021] Figure 2 A logical schematic diagram of a message broadcasting method in a cluster provided by an exemplary embodiment of the present application;
[0022] Figure 3 A schematic diagram of an application scheme of a message broadcasting method in a cluster provided by an exemplary embodiment of the present application;
[0023] Figure 4a A schematic diagram of a node sequence structure provided for an exemplary embodiment of the present application;
[0024] Figure 4b A schematic diagram of a propagation sequence provided for an exemplary embodiment of the present application;
[0025] Figure 5 A schematic diagram of a cluster topology structure provided for an exemplary embodiment of the present application;
[0026] Figure 6 A schematic diagram of the structure of a node provided for another exemplary embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0028] At present, the message broadcasting pressure in the cluster is concentrated on the source node. When the cluster scale increases, the message broadcasting load of a single node is too large and the performance is poor, which in turn will limit the node scale of the cluster. To this end, in some embodiments of the present application: a cluster topology structure generated by organizing the cluster with itself as the root node is configured for each node in the cluster. Based on this, for any node in the cluster, after receiving the message to be broadcast, the cluster topology structure corresponding to the source node to which the message belongs can be determined; in the cluster topology structure corresponding to the source node, the child node associated with the target node itself is determined; and the message is propagated to the child node. In this way, for a message, it is no longer completely dependent on the source node to which it belongs for broadcasting, but many nodes in the cluster relay broadcasting according to the cluster topology structure corresponding to the source node to share the message broadcasting load, which prevents the message broadcasting load of a single node from increasing excessively due to the expansion of the cluster scale, and thus can support better scalability of the cluster.
[0029] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0030] Figure 1 A schematic diagram of a flow chart of a message broadcasting method in a cluster provided by an exemplary embodiment of the present application, Figure 2A logical diagram of a message broadcast method in a cluster provided by an exemplary embodiment of the present application. The method can be executed by a data processing device, which can be implemented as a combination of software and / or hardware, and the data processing device can be integrated in any node in the cluster. Figure 1 , the method comprising:
[0031] Step 100: receiving a message to be broadcast;
[0032] Step 101: determine a cluster topology structure corresponding to a source node to which a message belongs, wherein each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node;
[0033] Step 102: In the cluster topology corresponding to the source node, determine the child node associated with the target node itself;
[0034] Step 103: propagate the message to the child nodes, so that the child nodes continue to propagate the message according to the cluster topology structure corresponding to the source node, until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
[0035] In this embodiment, the cluster can be a distributed cluster, such as a Redis cluster, etc., but it should be understood that the application scenarios, scale, etc. of the cluster are not limited in this embodiment. In a cluster, there are often some messages that must be propagated to all nodes, that is, messages that need to be broadcast to ensure that each node in the cluster can receive them. For example, a subscription-consumption mechanism can be used to manage messages in the cluster, and all nodes in the cluster can subscribe to the same channel. In this case, messages that appear under this channel need to be propagated to all nodes in the cluster, that is, messages that need to be broadcast. For messages that need to be broadcast in the cluster, this embodiment provides a message broadcasting solution that can prevent the message broadcasting load of a single node in the cluster from being overly affected by the size of the cluster.
[0036] For ease of description, this embodiment will take the target node in the cluster as an example to illustrate the message broadcasting scheme. It should be understood that the target node can be any node in the cluster.
[0037] refer to Figure 1 and Figure 2 In step 100, the target node may receive the message to be broadcast. The message may come from a user terminal communicating with the cluster or from other clusters, and the present embodiment does not limit the source of the message. In addition, the present embodiment does not limit the message type, actual content, etc. in the message. The present embodiment mainly focuses on whether the message entering the cluster needs to be propagated to all nodes, that is, whether the message needs to be broadcast, and does not make too many restrictions on other dimensions of the message.
[0038] In step 101, the cluster topology corresponding to the source node to which the message belongs may be determined. The source node refers to the node in the cluster that first receives the message, and the node is usually directly facing the sender of the message. For example, when user A initiates a message, node B in the cluster receives the message facing user A, and node B will receive the message first. Node B is the source node to which the message belongs. In this embodiment, the message may include a source node identifier, and the target node may determine whether the source node of the message is the target node itself based on the source node identifier of the message.
[0039] Here, the cluster topology structure can be understood as the propagation path of the message in the cluster. For example, the cluster topology structure can be a tree structure, a mesh structure, etc. In this embodiment, each node in the cluster can be configured with a cluster topology structure with itself as the root node. For example, if the cluster contains N nodes, N cluster topologies can be organized, each node corresponds to a cluster topology structure, and the cluster topology structure of the i-th node takes the i-th node as the root node. In this way, the N cluster topologies will be different. In this way, for the cluster topology structure corresponding to the target node, the target node will be used as the root node, and the other nodes in the cluster will be organized to generate a non-discrete topology structure, that is, starting from the root node, each of the other nodes in the cluster has at least one propagation path that can reach the root node.
[0040] Based on this, in step 101, the cluster topology structure corresponding to the determined source node is the source node as the root node, and each of the other nodes in the cluster has at least one propagation path that can reach the root node. In this way, in step 102, the target node can determine the child node associated with itself in the cluster topology structure corresponding to the source node. Here, the child node refers to the node that is located after the target node and directly associated with the target node when the root node is used as the propagation starting point.
[0041] refer to Figure 1 and Figure 2, in step 103, the target node can propagate the message to the child nodes so that the child nodes can continue to propagate the message according to the cluster topology structure corresponding to the source node. It can be seen that the target node shares the message broadcasting pressure of the source node, and the source node no longer needs to propagate the message to the child nodes associated with the target node, but the target node takes on this part of the work. The child nodes of the target node will continue to relay and propagate the message backward until the message is propagated to all nodes in the cluster topology structure corresponding to the source node. For the source node to which the message belongs, it only needs to bear the responsibility of propagating the message to the child nodes associated with the source node in the cluster topology structure corresponding to the source node. For other nodes in the cluster, when receiving the message, they can share the message broadcasting pressure of the source node and pass the message backward to the child nodes associated with themselves according to the cluster topology structure corresponding to the source node. During the entire broadcast process of the message, all nodes in the cluster share the message broadcast pressure. All nodes are based on the cluster topology corresponding to the source node to which the message belongs. Starting from the source node, subsequent nodes continuously relay the message to all nodes in the cluster, which forms a relay propagation mode. Many nodes in the cluster share the message broadcast work, instead of concentrating on the source node, which can effectively alleviate the message propagation load of the source node. Even if the cluster scale is expanded, it will not cause excessive increase in the complexity of the source node's message propagation, so it has better adaptability to the cluster scale.
[0042] Preferably, in this embodiment, in the cluster topology structure corresponding to the source node, except for the source node, other nodes in the cluster may have only one propagation entry, which can ensure that each node in the cluster receives the message only once, thereby avoiding the problem of repeated broadcasting. The number of propagation exits of each node in the cluster topology structure corresponding to the source node is not limited and can be adaptively determined according to the topology structure type adopted by the cluster topology structure corresponding to the source node.
[0043] Figure 3 A schematic diagram of an application scheme of a message broadcast method in a cluster provided by an exemplary embodiment of the present application. Figure 3, for the target node, if it is determined that the source node to which the message belongs is the target node itself, the child node associated with the target node itself can be determined in the cluster topology structure corresponding to the target node itself; the message is propagated to the child node, so that the child node can continue to propagate the message according to the cluster topology structure corresponding to the target node itself, until the message is propagated to all nodes in the cluster topology structure corresponding to the target node itself. In this case, the target node is the source node to which the message belongs. The target node can propagate the message to the child node associated with the target node itself according to its corresponding cluster topology structure, and the child node will continue to propagate the message backward according to the cluster topology structure corresponding to the target node until the message is broadcast to all nodes in the cluster. The target node can also add various information required for subsequent relay propagation to the message, including but not limited to the source node identifier, message sequence number, cluster topology type or cluster version number of the source node, etc., for reference by other nodes in the cluster.
[0044] In addition, refer to Figure 3 In this embodiment, a transmission mode switching mechanism can be introduced. In this embodiment, at least two transmission modes can be provided, namely Figure 1 The first mode shown in the figure, and the second mode of traditionally propagating messages to other nodes in the cluster through a single node. Of course, more propagation modes can be added in this embodiment to adapt to different application scenario requirements. To this end, in this embodiment, a propagation mode identifier can be configured for each propagation mode, and different propagation modes correspond to different propagation mode identifiers. Based on this, in a possible design, the propagation mode switching logic can be deployed in the message receiving layer, that is, the propagation mode identifier can be carried in the message, and the node receiving the message can know which propagation mode needs to be adopted for the message according to the propagation mode identifier.
[0045] refer to Figure 3 In this embodiment, after receiving the message, the propagation mode identifier contained in the message can be identified to determine which propagation mode to use:
[0046] If it is determined according to the propagation mode identifier contained in the message that the propagation mode required by the message is the first mode, then determining whether the source node to which the message belongs is the target node itself and subsequent operations are performed;
[0047] If the propagation mode required by the message is determined to be the second mode according to the propagation mode identifier contained in the message, the message is propagated to other nodes in the cluster respectively, without performing the determination of whether the source node to which the message belongs is the target node itself and subsequent operations.
[0048] It should be understood here that no matter whether the target node is the source node to which the message belongs, the above-mentioned propagation mode judgment operation can be performed to determine the propagation mode that it should adopt for the message.
[0049] In this embodiment, the introduction of the propagation mode switching mechanism can make our technical solution have unparalleled compatibility and freedom. For example, if the current cluster is full of old version target nodes themselves, if there is no propagation mode switching mechanism, we can only wait for the nodes to be completely replaced before upgrading the propagation mode, and there is no way to achieve online upgrade; and after the introduction of the propagation mode switching mechanism, the default mode can be set to the second mode, which is compatible with the old version of the target node itself, and can be seamlessly switched to the first mode after all nodes are successfully upgraded, and more types of propagation modes can be connected. Therefore, the introduction of the propagation mode switching mechanism can help select a propagation mode with better message broadcasting performance in different situations. For example, when the user thinks that the cluster scale is too large, he can select the first mode and configure the propagation mode identifier of the first mode in the message to reduce the load of a single node in the cluster, and when the cluster scale is considered small, he can select the second mode and configure the propagation mode identifier of the second mode in the message to broadcast messages through a single node.
[0050] Accordingly, in this embodiment, for a message, it is no longer completely dependent on the source node to which it belongs to perform broadcasting. Instead, many nodes in the cluster perform relay broadcasting in accordance with the cluster topology structure corresponding to the source node to share the message broadcasting load. This ensures that the message broadcasting load of a single node will not increase excessively due to the expansion of the cluster scale, and thus can support better scalability of the cluster. Moreover, since many nodes in the cluster perform relay broadcasting in accordance with the cluster topology structure of the source node, the total amount of message packets actually occurring during the message transmission process does not increase, and the problem of repeated broadcasting does not occur, which effectively saves processing resources and ensures broadcasting efficiency.
[0051] In the above or following embodiments, the target node may adopt a variety of implementation methods to determine the cluster topology structure corresponding to the source node.
[0052] In an optional implementation: a node sequence for cluster formation may be obtained; the position of a source node (which may be the target node itself or other nodes in the cluster) in the node sequence may be determined; the nodes preceding the source node may be sequentially moved to the end of the node sequence to generate a propagation sequence corresponding to the source node; and the cluster may be organized according to the propagation sequence corresponding to the source node to generate a cluster topology structure corresponding to the source node.
[0053] The node sequence refers to a queue generated by arranging the nodes in the cluster in a certain order. Figure 4a A schematic diagram of a node sequence structure provided by an exemplary embodiment of the present application. Figure 4a, the cluster contains 5 nodes in total, and the nodes in the node sequence are node 0, node 1, node 2, node 3 and node 4. In this implementation, the order of the nodes in the node sequence can be determined by sorting the nodes according to the globally unique code UUID of each node. Of course, the sorting basis is not limited to UUID, and the nodes can also be sorted according to other criteria.
[0054] Preferably, in this implementation, the cluster topology corresponding to each node in the cluster can all be derived from the same node sequence, that is, each node in the cluster recognizes and follows the same node sequence to perform the determination operation of the cluster topology of itself or other nodes. In this way, in practical applications, the control center in the cluster only needs to provide the node sequence formed for the cluster to each node in the cluster, so that each node can follow the same node sequence. In the case of increase / decrease of nodes in the cluster, the control center can also synchronize the updated node sequence to each node in the cluster to ensure that the nodes follow the same and latest node sequence. Of course, this embodiment is not limited to this, and different node sequences can also be configured for different source nodes. However, for the same source node, each node in the cluster needs to follow the same node sequence to construct the cluster topology corresponding to the source node to ensure that each node can relay messages according to the same cluster topology.
[0055] On this basis, in this implementation, the position of the source node in the node sequence can be determined. Figure 4a , if node 2 is the source node of the message, the position of node 2 in the node sequence can be determined. Then, the nodes before the source node can be moved to the end of the node sequence to generate the propagation sequence corresponding to the source node. Figure 4b A schematic diagram of a propagation sequence provided by an exemplary embodiment of the present application, with reference to Figure 4b ,exist Figure 4a When node 2 is the source node, the propagation sequence can be obtained after the node movement. It can be seen that node 0 and node 1 before node 2 are moved to the end of the node sequence in sequence. The order of nodes in the propagation sequence is node 2, node 3, node 4, node 0 and node 1. Obviously, the node order has changed.
[0056] In this implementation, the cluster can be organized according to the propagation sequence corresponding to the source node to generate a cluster topology structure corresponding to the source node. It should be understood here that the generated cluster topology structure only needs to ensure that the message can be received by each node in sequence according to the node order in the propagation sequence, and the shape of the cluster topology structure is not limited. As submitted above, the cluster topology structure can be a tree structure, a mesh structure, etc. Taking the tree structure as an example, in this implementation: according to the propagation sequence corresponding to the source node, the nodes in the cluster can be organized into a tree structure in order as the cluster topology structure corresponding to the source node. Figure 5 A schematic diagram of a cluster topology structure provided by an exemplary embodiment of the present application. Figure 5 , undertake Figure 4b The node sequence in the propagation sequence can be used as the target, and the message can be received by each node in turn according to the node order in the propagation sequence, so as to construct Figure 5 The cluster topology structure corresponding to the source node can also adopt a tree structure, which can be an N-ary tree, where N can be an integer greater than or equal to 2. Figure 5 The binary tree structure shown is only exemplary, and the cluster topology structure of the source node may also adopt a ternary tree, a quadtree, etc. In order to ensure that each node in the cluster uses the same cluster topology structure for the same source node, preferably, the cluster topology structure type adopted by the source node, such as a tree structure type, may be carried in the message. In this way, for the target node, the nodes in the cluster may be organized in sequence into a cluster topology structure that conforms to the cluster topology structure type according to the propagation sequence corresponding to the source node and the cluster topology structure type adopted. Still taking the tree structure as an example, the target node may organize the nodes in the cluster in sequence into a tree structure that conforms to the tree structure type according to the propagation sequence corresponding to the source node and the tree structure type adopted. Reference Figure 5 , the message can carry the identifier corresponding to the binary tree structure, so that the target node can organize the nodes in the cluster in order according to the propagation sequence corresponding to the source node. Figure 5 The binary tree structure shown.
[0057] Accordingly, in this implementation, each node in the cluster can use the node sequence as a basis to calculate the cluster topology structure corresponding to the source node in real time, and for the same source node, each node in the cluster can calculate the same cluster topology structure, which can ensure that each node in the cluster relays the same message according to the same cluster topology structure to ensure the comprehensiveness of the message broadcast and avoid duplication.
[0058] Of course, in this embodiment, the target node may also use other implementation methods to determine the cluster topology structure corresponding to the source node. For example, the cluster topology structure may be constructed for each node in the cluster in advance, and the cluster topology structures corresponding to all nodes in the cluster may be stored in each node, and the node does not need to calculate the cluster topology structure in real time. For another example, the cluster topology structure constructed for each node in the cluster may be stored in the control center of the cluster, and each node may request the cluster topology structure corresponding to the source node from the control center when needed. These implementation methods are also only exemplary, and this embodiment is not limited thereto.
[0059] In this embodiment, each node in the cluster can respectively determine the cluster topology structure corresponding to the source node to which the message belongs, and the cluster topology structure determined by each node is consistent, which ensures that each node can relay the message according to the same cluster topology structure to ensure that the message can be propagated to all nodes in the cluster.
[0060] In the above or below embodiments, a compensation mechanism may also be introduced.
[0061] refer to Figure 3 , for the target node, an exemplary compensation scheme may be: if the propagation of the message to the child node times out, then in the cluster topology corresponding to the source node, determine the next-level node of the child node associated with the target node itself; propagate the message to the next-level node, so that the next-level node continues to propagate the message according to the cluster topology corresponding to the source node. That is, in this embodiment, the parent node may provide compensation for the child node, that is, when a child node fails and the parent node propagates the message for a timeout, the parent node may bypass the child node and directly propagate the message to the next-level node of the failed child node to ensure that other nodes in the topology branch where the failed child node is located can receive the message normally. For example, refer to Figure 5 The cluster topology corresponding to the source node shown in the figure, if node 2 times out in propagating a message to node 3, node 2 can bypass node 3 and propagate the message to node 0.
[0062] When a compensation mechanism is introduced, there will be a situation where, although the message propagation timeout occurs, the message receiver may have only experienced a slow query, but no failure has occurred, and the message has actually been received. In this case, a duplicate broadcast problem may occur. In order to avoid duplicate broadcasts, a deduplication mechanism may be introduced in this embodiment.
[0063] For the target node, an exemplary deduplication scheme may be: carry the source node identifier and message sequence number in the message, based on which, the message propagation record maintained for the source node can be searched, and the message propagation record contains the message sequence number of the message that has been propagated by the source node; if the message sequence number contained in the message already exists in the message propagation record, the message is determined to be a duplicate message and is no longer propagated; if the message sequence number contained in the message does not exist in the message propagation record, after completing the operation of propagating the message to the child node, the message sequence number contained in the message is written into the message propagation record. In this exemplary scheme, the target node can maintain message propagation records for other nodes in the cluster respectively, so that it can accurately determine whether the message sequence number of the message already exists in the message propagation record of the source node to which it belongs, so as to accurately find the problem of repeated broadcasting. If it is found that the message is a repeated received message, the target node will no longer perform subsequent propagation for the message, and if the message is not a repeated received message, the target node will normally propagate the message to its child nodes, and write the message sequence number corresponding to the message into the message propagation record corresponding to the source node to which the message belongs.
[0064] Of course, in this embodiment, other deduplication schemes can also be used. For example, for the source node, the message sequence number of the message it sends can be incremental. Based on this, when the target node receives the message, it can compare the message sequence number contained in the message with the latest message sequence number stored in the target node for the source node to which the message belongs. If the message sequence number contained in the message is less than or equal to the latest message sequence number stored in the target node for the source node to which the message belongs, it can be determined that the message is a duplicate message. Otherwise, it can be determined that the message is not a duplicate message, and the latest message sequence number stored in the target node for the source node to which the message belongs is updated to the message sequence number contained in the message. Under this exemplary scheme, the target node only needs to store the message sequence number of the latest message it has propagated to each node in the cluster, without having to store the message sequence numbers of all messages that have been propagated, which can effectively reduce the storage pressure of the node.
[0065] In addition, in this embodiment, an overload protection mechanism may also be introduced.
[0066] For the target node, an exemplary overload protection scheme may be: using the message counter on the target node itself to detect the number of unprocessed messages in the message queue on the target node itself; if the number of unprocessed messages exceeds the preset threshold, the first message in the message queue is discarded and the first message is no longer propagated. For example, assuming that the target node's ability to push messages is W / second, that is, when the child node cannot reply to the target node itself within one second, W messages (unprocessed callbacks) will be accumulated in the message queue. In an extreme case, when the message transmission to the descendant nodes also fails, 2W messages will be accumulated, and in extreme cases, a large number of messages will be accumulated. By setting a message counter, it can be added by one when the target node receives a message, and subtracted by one when the target node successfully propagates the message, so that the number of unprocessed messages in the message queue on the target node itself can be detected by the message counter, and when the number of unprocessed messages exceeds the preset threshold, a high water mark callback can be set. At this time, you can choose to directly reject the propagation of the first message in the message queue to solve the overload problem from the source. In addition, in this exemplary overload protection scheme, a notification may be sent to the user to which the first message in the discarded message queue belongs. Typically, in this case, the user may receive the processing result, and the user may also re-initiate a broadcast request for the discarded message.
[0067] The overload protection mechanism can avoid the overload problem of a single node caused by congestion of a single message, thereby avoiding message broadcast overload and occupying the processing resources on a single node and affecting other functions on the single node.
[0068] In this embodiment, when each node needs to calculate the cluster topology structure corresponding to the source node in real time, a propagation mode degradation mechanism may also be introduced.
[0069] refer to Figure 3 For the target node, an exemplary propagation mode degradation mechanism may be: the message includes a cluster version number, and the cluster version number is used to indicate a cluster scale change event. In this way, before determining the cluster topology structure corresponding to the source node, it is also possible to determine whether the cluster version number included in the message is consistent with the latest cluster version number recorded by the target node itself. If they are inconsistent, the message is propagated to other nodes in the cluster respectively, and the cluster topology structure corresponding to the source node and subsequent operations are no longer determined.
[0070] For the target node, if its current cluster version number is inconsistent with the cluster version number in the message, the target node will calculate the cluster topology corresponding to the source node according to a node sequence different from that of the source node, which will cause the target node to be unable to propagate the message according to the latest cluster topology corresponding to the source node. However, other nodes in the cluster may propagate the message according to the latest cluster topology corresponding to the source node. This will cause the cluster topology based on which each node in the cluster propagates the message to be inconsistent, resulting in some nodes in the cluster being unable to receive the message, that is, the problem of incomplete broadcasting. For this reason, in this exemplary propagation mode degradation mechanism, if the target node finds that its current cluster version number is inconsistent with the cluster version number in the message, the target node will no longer propagate the message according to the message broadcast scheme provided in this embodiment, but will degenerate to the traditional propagation mode, that is, the message is propagated to other nodes in the cluster separately to ensure that all nodes in the cluster can receive the message. The message propagation scheme provided in this embodiment will be restored after the cluster version number is transmitted to all nodes in the cluster.
[0071] It should be noted that in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel, and the sequence numbers of the operations, such as 101, 102, etc., are only used to distinguish between the different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different modes, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0072] Figure 6 FIG. 1 is a schematic diagram of a node structure provided by another exemplary embodiment of the present application. Figure 6 As shown, the computing device includes: a memory 60 , a processor 61 , and a communication component 62 .
[0073] The processor 61 is coupled to the memory 60 and the communication component 62, and is used to execute the computer program in the memory 60, so as to:
[0074] Receiving a message to be broadcast via the communication component 62;
[0075] Determine a cluster topology structure corresponding to the source node, wherein each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node;
[0076] In the cluster topology corresponding to the source node, determine the child nodes associated with the target node itself;
[0077] The message is propagated to the child nodes through the communication component 62, so that the child nodes continue to propagate the message according to the cluster topology structure corresponding to the source node until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
[0078] The node in this embodiment may be any node in the cluster. It should be understood that the node in the cluster may be a virtual node or an actual physical server, etc. This embodiment does not limit the implementation form of the node.
[0079] In an optional embodiment, the processor 61 is further configured to:
[0080] If the source node to which the message belongs is the target node itself, then the child node associated with the target node itself is determined in the cluster topology structure corresponding to the target node itself;
[0081] The message is propagated to the child nodes, so that the child nodes continue to propagate the message according to the cluster topology structure corresponding to the target node itself, until the message is propagated to all nodes in the cluster topology structure corresponding to the target node itself.
[0082] In an optional embodiment, the message includes a propagation mode identifier, and after receiving the message to be broadcast, the processor 61 is further configured to:
[0083] If it is determined according to the propagation mode identifier contained in the message that the propagation mode required by the message is the first mode, then determining whether the source node to which the message belongs is the target node itself and subsequent operations are performed;
[0084] If the propagation mode required by the message is determined to be the second mode according to the propagation mode identifier contained in the message, the message is propagated to other nodes in the cluster respectively, without performing the determination of whether the source node to which the message belongs is the target node itself and subsequent operations.
[0085] In an optional embodiment, when determining the cluster topology corresponding to the source node to which the message belongs, the processor 61 is configured to:
[0086] Get the node sequence formed for the cluster;
[0087] Determine the position of the source node in the node sequence;
[0088] Move the nodes before the source node to the end of the node sequence in order to generate the propagation sequence corresponding to the source node;
[0089] According to the propagation sequence corresponding to the source node, the cluster is organized to generate a cluster topology corresponding to the source node.
[0090] In an optional embodiment, the cluster topology structure corresponding to each node in the cluster is derived from the same node sequence.
[0091] In an optional embodiment, when the processor 61 organizes the clusters according to the propagation sequence to generate the cluster topology structure corresponding to the source node, it is configured to:
[0092] According to the propagation sequence corresponding to the source node, the nodes in the cluster are organized into a tree structure in order as the cluster topology structure corresponding to the source node.
[0093] In an optional embodiment, the message includes the tree structure type adopted by the source node, and the processor 61 organizes the nodes in the cluster into a tree structure in sequence according to the propagation sequence corresponding to the source node, and is used to:
[0094] According to the propagation sequence corresponding to the source node and the adopted tree structure type, the nodes in the cluster are organized in sequence into a tree structure that conforms to the tree structure type.
[0095] In an optional embodiment, the processor 61 is further configured to:
[0096] If the propagation of the message to the child node times out, the next level node of the child node associated with the target node itself is determined in the cluster topology corresponding to the source node;
[0097] The message is propagated to the next-level node so that the next-level node continues to propagate the message according to the cluster topology structure corresponding to the source node.
[0098] In an optional embodiment, the message includes a source node identifier and a message sequence number, and the processor 61 is further configured to:
[0099] Find the message propagation record maintained for the source node, the message propagation record contains the message sequence number of the message that has been propagated by the source node;
[0100] If the message sequence number contained in the message already exists in the message propagation record, the message is determined to be a duplicate message and is no longer propagated;
[0101] If the message sequence number included in the message does not exist in the message propagation record, after completing the operation of propagating the message to the child node, the message sequence number included in the message is written into the message propagation record.
[0102] In an optional embodiment, each node in the cluster is configured with a message counter, and the processor 61 is further configured to:
[0103] Using the message counter on the target node itself to detect the number of unprocessed messages in the message queue on the target node itself;
[0104] If the number of unprocessed messages exceeds a preset threshold, the first message in the message queue is discarded and the first message is no longer propagated.
[0105] In an optional embodiment, the message includes a cluster version number, and the cluster version number is used to indicate a cluster scale change event. Before determining the cluster topology structure corresponding to the source node to which the message belongs, the processor 61 is further used to:
[0106] If the cluster version number contained in the message is inconsistent with the latest cluster version number recorded by the target node itself, the message will be propagated to other nodes in the cluster respectively, and the cluster topology structure and subsequent operations corresponding to the source node to which the message belongs will no longer be determined.
[0107] Further, if Figure 6 As shown, the node also includes: a power supply component 63 and other components. Figure 6 Only some components are shown schematically, which does not mean that the node only includes Figure 6 Components shown.
[0108] It is worth noting that the technical details in the above-mentioned node embodiments can be referred to the relevant description in the aforementioned method embodiments. In order to save space, they will not be repeated here, but this should not cause a loss in the scope of protection of this application.
[0109] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed, can implement each step that can be executed by a node in the above method embodiment.
[0110] Above Figure 6 The memory in the computer is used to store computer programs and can be configured to store various other data to support operations on the computing platform. Examples of such data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0111] Above Figure 6The communication component in is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0112] Above Figure 6 The power supply component in the device provides power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.
[0113] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0114] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0115] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0117] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0118] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0119] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0120] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0121] The above is only the embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A message broadcasting method in a cluster, applicable to a target node in the cluster, the method comprising: Receive messages to be broadcast; Obtaining a node sequence formed for the cluster; Determine the position of the source node to which the message belongs in the node sequence; The nodes before the source node are sequentially moved to the end of the node sequence to generate a propagation sequence corresponding to the source node; the cluster is organized according to the propagation sequence corresponding to the source node to generate a cluster topology structure corresponding to the source node, wherein each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node; In the cluster topology corresponding to the source node, determining the child node associated with the target node itself; The message is propagated to the child node, so that the child node continues to propagate the message according to the cluster topology structure corresponding to the source node, until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
2. The method according to claim 1, wherein the message includes a propagation mode identifier, and after receiving the message to be broadcast, the method further comprises: If it is determined according to the propagation mode identifier contained in the message that the propagation mode required by the message is the first mode, then determining whether the source node to which the message belongs is the target node itself and subsequent operations are performed; If the propagation mode required by the message is determined to be the second mode according to the propagation mode identifier contained in the message, the message is propagated to other nodes in the cluster respectively, and the determination of whether the source node to which the message belongs is the target node itself and subsequent operations are no longer performed.
3. According to the method of claim 1, the cluster topology structure corresponding to each node in the cluster is derived from the same node sequence.
4. The method according to claim 1, organizing the cluster according to the propagation sequence to generate a cluster topology structure corresponding to the source node, comprising: According to the propagation sequence corresponding to the source node, the nodes in the cluster are organized into a tree structure in sequence as the cluster topology structure corresponding to the source node.
5. The method according to claim 4, wherein the message includes a tree structure type adopted by the source node, and the nodes in the cluster are organized into a tree structure in sequence according to a propagation sequence corresponding to the source node, comprising: According to the propagation sequence corresponding to the source node and the adopted tree structure type, the nodes in the cluster are organized in sequence into a tree structure that conforms to the tree structure type.
6. The method according to claim 1, further comprising: If the propagation of the message to the child node times out, determining the next level node of the child node associated with the target node itself in the cluster topology structure corresponding to the source node; The message is propagated to the next-level node, so that the next-level node continues to propagate the message according to the cluster topology structure corresponding to the source node.
7. The method according to claim 6, wherein the message includes a source node identifier and a message sequence number, and the method further comprises: Searching for a message propagation record maintained for the source node, the message propagation record including a message sequence number of a message that has been propagated for the source node; If the message sequence number included in the message already exists in the message propagation record, the message is determined to be a duplicate message and is not propagated any further; If the message sequence number included in the message does not exist in the message propagation record, after completing the operation of propagating the message to the child node, the message sequence number included in the message is written into the message propagation record.
8. The method according to claim 1, wherein each node in the cluster is configured with a message counter, and the method further comprises: Using the message counter on the target node itself to detect the number of unprocessed messages in the message queue on the target node itself; If the number of unprocessed messages exceeds a preset threshold, the first message in the message queue is discarded and the first message is no longer propagated.
9. The method according to claim 1, wherein the message includes a cluster version number, and the cluster version number is used to indicate a cluster scale change event. Before determining the cluster topology structure corresponding to the source node to which the message belongs, the method further includes: If the cluster version number included in the message is inconsistent with the latest cluster version number recorded by the target node itself, the message is propagated to other nodes in the cluster respectively, and the cluster topology structure corresponding to the source node to which the message belongs and subsequent operations are no longer performed.
10. A node comprising a memory, a processor and a communication component; The memory is used to store one or more computer instructions; The processor is coupled to the memory and the communication component and is configured to execute the one or more computer instructions for: receiving a message to be broadcasted via the communication component; Obtain a node sequence for cluster formation; determine the position of the source node to which the message belongs in the node sequence; sequentially move the nodes before the source node to the end of the node sequence to generate a propagation sequence corresponding to the source node; organize the cluster according to the propagation sequence corresponding to the source node to generate a cluster topology structure corresponding to the source node, wherein: Each node in the cluster is configured with a cluster topology structure generated by organizing the cluster with itself as a root node; In the cluster topology corresponding to the source node, determining the child node associated with the target node itself; The message is propagated to the child node through the communication component, so that the child node continues to propagate the message according to the cluster topology structure corresponding to the source node until the message is propagated to all nodes in the cluster topology structure corresponding to the source node.
11. A computer-readable storage medium storing computer instructions, which, when executed by one or more processors, causes the one or more processors to execute the message broadcasting method in a cluster according to any one of claims 1 to 9.
