System topology maintenance method, device, computer equipment and storage medium
By receiving and processing renewal requests sent by random value time intervals of service nodes in a distributed system, and generating and sending system topology information, the network storm problem caused by traditional methods is solved, and the stability and business continuity of the system are improved.
Patent Information
- Application Number
- CN202110525500.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-13
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-05-13
AI Technical Summary
In the distributed system environment of large-scale node clusters, traditional polling or callback methods lead to a storm in the central node network, affecting business continuity.
By receiving renewal requests sent at random value intervals of service nodes, system topology information is generated, and sent after waiting for at least two consecutive renewal cycles, the resource overhead of the central node is reduced and network storms are avoided.
It improves the stability of the topology maintenance of the central node, reduces the processing burden of the central node, avoids network storms, and ensures business continuity.
Smart Images

Figure CN113497737B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed system management, and in particular to a system topology maintenance method, device, computer equipment and storage medium. Background Art
[0002] With the development of the Internet, the user scale and data scale are getting larger and larger, which puts higher requirements on the performance of the system. Therefore, distributed systems are becoming popular.
[0003] Common algorithms in distributed systems, such as distributed cache algorithms and consistent hashing algorithms, can quickly sense the online or faulty status of each business node, thereby achieving rapid service switching and ensuring that key businesses are not interrupted. In traditional methods, distributed systems use polling, callback, or invalidation to sense the online or faulty status of each node, thereby maintaining the topological structure of each node in the distributed system.
[0004] However, in a distributed system environment with a large-scale node cluster, whether it is the polling method, callback or invalidation method, a large number of business nodes or clients simultaneously update topology messages to the central node, which often causes a network storm in the central node and affects normal business. Summary of the invention
[0005] Based on this, it is necessary to provide a system topology maintenance method, device, computer equipment and storage medium to address the above technical problems.
[0006] A system topology maintenance method, the method comprising:
[0007] Receiving a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval;
[0008] In response to each of the renewal requests, generating system topology information according to the node identification information in the renewal request;
[0009] After waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is complete, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information.
[0010] In this embodiment, when the central node takes over the distributed system, it receives renewal requests sent by the business nodes at random time intervals, and rebuilds the system topology information based on the node identification information in the renewal request, thereby reducing the resource overhead of the central node and avoiding network storms when the central node rebuilds the topology information, thereby improving the stability of the central node's topology maintenance.
[0011] In one of the embodiments, after receiving the renewal request from each service node, the method further includes:
[0012] According to the local power-on clock information, the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request are recorded.
[0013] In this embodiment, for the renewal request sent by the service node, the timestamp information carried in the renewal request sent by the service node is not used. Instead, the central node's own startup clock system is used to record the time of the received renewal request to ensure the uniformity of the time information of each renewal request.
[0014] In one embodiment, the method further comprises:
[0015] If no renewal request of the target service node is received within a preset time range threshold, it is determined that the target service node is faulty; the time threshold range is greater than or equal to the renewal period corresponding to the target service node;
[0016] Deleting the target service node in the system topology information to obtain updated system topology information;
[0017] The business nodes in the business node cluster are divided according to a preset business node number division mechanism to obtain the division results and the corresponding notification sequence information, and the updated system topology information is broadcast in batches to other business nodes in the business node cluster except the target business node according to the division results and the corresponding sequence information to instruct the other business nodes to update the system topology information.
[0018] In this embodiment, the central node senses the failure of the service node by not receiving the renewal request of the target service node within a preset time range threshold, and then updates the system node topology information, and sends the updated system topology information to the service nodes in the service node cluster in multiple batches (i.e., in batches). Sending the system node topology information in batches multiple times reduces the processing burden of the central node and avoids network storms at the central node.
[0019] In one embodiment, the method further comprises:
[0020] Updating the consistent hash ring of the service node cluster, transferring the hash ring interval corresponding to the faulty service node to a target service node other than the faulty service node in the service node cluster, and adding the faulty service node to the silent zone of the consistent hash ring;
[0021] Receive a first service processing request sent by a client, and send the first service processing request to a corresponding processing node for processing;
[0022] If the processing node is the faulty service node, recalculate the node identifier of the processing node corresponding to the first service processing request according to the consistent hashing algorithm, and forward the first service processing request to the updated target service node according to the calculated node identifier to instruct the target service node to return processing failure information;
[0023] Waiting for a silent period, deleting the faulty service node from the silent zone of the consistent hash ring; the silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring;
[0024] The second service processing request sent by the client is received to instruct the target service node to process the second service processing request, and return a processing success message to the client.
[0025] In this embodiment, after the central node deletes the faulty service node, it waits for a silent period to avoid the faulty service node recalculating the new target service node determined by the processing node to process the service request together after receiving the first service processing request, thereby causing a network storm due to the concurrency of processing results, thereby improving the network stability of the distributed system.
[0026] In one embodiment, the method further comprises:
[0027] Receive a new renewal request sent by a new service node;
[0028] In response to the newly added renewal request, updating system topology information according to the newly added renewal request;
[0029] The business nodes in the business node cluster are divided according to a preset business node number division mechanism to obtain division results and corresponding notification sequence information, and the updated system topology information is broadcast in batches to each business node in the business node cluster and the newly added business nodes according to the division results and the corresponding sequence information to instruct each business node in the business node cluster and the newly added business nodes to update the system topology information.
[0030] In this embodiment, the central node perceives the renewal request of the newly added business node, and then updates the system node topology information, and sends the updated system topology information to the business nodes in the business node cluster in multiple batches (i.e., in batches). Sending the system node topology information in batches multiple times reduces the processing burden of the central node and avoids network storms in the central node.
[0031] In one embodiment, the method further comprises:
[0032] Updating the consistent hash ring of the service node cluster, and adding the newly added service node to the silent zone of the consistent hash ring;
[0033] Receive a third business processing request sent by the client, calculate a processing node identifier corresponding to the third business processing request according to a consistent hash algorithm, and send the third business processing request to a corresponding processing node for processing according to the processing node identifier;
[0034] If the processing node is a newly added service node, instructing the newly added service node to return processing failure information;
[0035] Waiting for a silent period until the newly added service node is in a normal operating state, receiving a fourth service processing request sent by the client, instructing the newly added service node to process the fourth service processing request, and returning the service processing success message to the client.
[0036] In this embodiment, the central node first sleeps for a silent period for the newly added service node, and then implements the processing function of the newly added service node, which does not affect the operation of other service nodes. New service nodes are flexibly added in the distributed system, improving the flexibility of node topology maintenance in the distributed system.
[0037] A system topology maintenance method, the method comprising:
[0038] At a time point generated by a preset random value time interval mechanism, a renewal request is sent to the central node, wherein the renewal request carries the node identification information of the service node itself; and the random value time interval is less than a preset time threshold;
[0039] Receive the system topology information sent by the central node, and update the local topology information according to the system topology information.
[0040] In one of the embodiments, the receiving the system topology information sent by the central node and updating the local topology information according to the system topology information includes:
[0041] Receiving system topology information sent by the central node, and comparing the system topology information with local topology information of the service node;
[0042] If the system topology information is inconsistent with the local topology information of the service node, the local topology information is updated according to the system topology information.
[0043] In this embodiment, by updating the service node topology information within the service node, it is avoided that the central node needs to determine whether each service node is updated, thereby reducing the processing pressure of the central node and avoiding network storms in the central node.
[0044] A system topology maintenance device, the device comprising:
[0045] A receiving module, used to receive a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval;
[0046] A generating module, configured to generate system topology information in response to each renewal request according to the node identification information in the renewal request;
[0047] The sending module is used to determine that the system topology reconstruction is completed after waiting for at least two consecutive renewal cycles, and send the system topology information to each renewed service node to instruct the service node to update the system topology information.
[0048] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0049] Receiving a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval;
[0050] In response to each of the renewal requests, generating system topology information according to the node identification information in the renewal request;
[0051] After waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is complete, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information.
[0052] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0053] Receiving a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval;
[0054] In response to each of the renewal requests, generating system topology information according to the node identification information in the renewal request;
[0055] After waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is complete, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information.
[0056] The above-mentioned system topology maintenance method, device, computer equipment and storage medium receive a renewal request from each service node, and the renewal request is sent by the service node according to a preset random value time interval; in response to each renewal request, the system topology information is generated according to the node identification information in the renewal request; after waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is completed, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information. With this method, when the central node takes over the distributed system, it only receives the renewal request sent by the service node at a random value time interval, and reconstructs the system topology information according to the node identification information in the renewal request, thereby reducing the resource overhead of the central node and avoiding network storms when the central node reconstructs the topology information, thereby improving the stability of the central node topology maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 An application environment diagram of a system topology maintenance method in one embodiment;
[0058] Figure 2 A schematic diagram of a process of maintaining a system topology structure in one embodiment;
[0059] Figure 3 A schematic diagram of a flow chart of steps for deleting a faulty service node in one embodiment;
[0060] Figure 4 A flowchart of the steps of updating the consistent hash ring of a service node cluster in one embodiment;
[0061] Figure 5 A schematic diagram of a flow chart of steps for adding a new service node in an embodiment;
[0062] Figure 6 A flowchart of the steps of updating the consistent hash ring of a service node cluster in another embodiment;
[0063] Figure 7 A schematic diagram of a flow chart of a system topology maintenance method in another embodiment;
[0064] Figure 8 A schematic diagram of a flow chart of the steps of updating and comparing system topology information of a service node in an embodiment;
[0065] Fig. 9 An example flow chart of adding a new service node to a distributed system in one embodiment;
[0066] Fig.10 An example flow chart of deleting a faulty service node in a distributed system in one embodiment;
[0067] Fig.11 A structural block diagram of a system topology maintenance device in one embodiment;
[0068] Fig.12 It is a structural block diagram of a system topology maintenance device in another embodiment;
[0069] Fig.13 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0071] The system topology maintenance method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the service node 102 communicates with the central node 104 through the network. The central node 104 receives the renewal request of each service node 102, and the renewal request is sent by the service node 102 according to a preset random value time interval; then, the central node 104 responds to each renewal request and generates system topology information according to the node identification information in the renewal request; after waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is completed, and the system topology information is sent to each renewed service node 102 to instruct the service node 102 to update the system topology information. Among them, the service node 102 can be but not limited to various personal computers, laptops, smart phones, tablet computers, and the central node 104 can be implemented with an independent server or a server cluster composed of multiple servers.
[0072] In one embodiment, Figure 2 As shown, a system topology maintenance method is provided, which is applied to Figure 1 Taking the central node 104 in the example as an example, the method includes the following steps:
[0073] Step 201: receiving a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval.
[0074] Specifically, in a distributed system, there are central nodes (also called central servers) and business nodes, among which the number of business nodes is generally much greater than that of central nodes. Multiple business nodes can form a business node cluster, which is uniformly managed and maintained by the central node. At the same time, in order to ensure the stability of the entire distributed system, multiple central nodes are also set up, and multiple central nodes serve as master and backup for each other. Only one main central node provides services at the same time, and the remaining central nodes (also called slave central nodes) serve as backups. Only when the main central node goes down, any other slave central node will take over the original main central node as the new main central node to provide management and maintenance services for the distributed system.
[0075] When providing management and maintenance services for the distributed system, the central node needs to master the node topology information of the distributed system. Therefore, the central node receives the renewal request of each service node to determine the service node information contained in the distributed system according to the node identification information of the service node carried in the renewal request. All the service node information in the distributed system constitutes the node topology information of the distributed system.
[0076] Among them, the renewal request is sent by each business node in the business node cluster of the distributed system at a preset random value time interval, and the random value time interval needs to be guaranteed to be less than the preset time range threshold to ensure the validity of each renewal request within the lease period.
[0077] Step 202: In response to each renewal request, generate system topology information according to the node identification information in the renewal request.
[0078] In implementation, the central node generates system node topology information (also referred to as system topology information) in response to each renewal request according to the node identification information carried in each renewal request.
[0079] Specifically, each renewal request carries the node serial number of its own service node, which is used to uniquely identify the service node. Then, the central node stores the node serial number of each renewal request and generates corresponding system topology information.
[0080] Step 203: after waiting for at least two consecutive renewal cycles, determine that the system topology reconstruction is complete, and send the system topology information to each renewed service node to instruct the service node to update the system topology information.
[0081] Each renewal period is the time interval between two consecutive renewal requests sent to a service node.
[0082] In implementation, after waiting for at least two consecutive renewal cycles, the central node determines that the system topology reconstruction is complete, and then sends the system topology information to each renewed service node to instruct the renewed service node to update the system node topology information.
[0083] Specifically, take the main central node downtime, and the slave central node taking over the system service as an example to explain, in order to prevent the main central node from downtime, when the slave central node initially takes over the service, the service nodes in the service node cluster have not completely converted the renewal request sending object, causing some service nodes to still send renewal requests to the downtime main central node, therefore, the slave central node needs to wait for two consecutive renewal cycles to ensure that within this time range, all service node renewal request sending objects have been converted to the slave central node, so the slave central node can determine that the system topology information has been rebuilt based on all the renewal requests received within this time range. Then, the slave central node (that is, the new main central node) sends the rebuilt topology information to each renewed service node to instruct the renewed service node to update its own topology information based on the rebuilt topology information.
[0084] In the above system topology maintenance method, a renewal request from each service node is received, and the renewal request is sent by the service node according to a preset random value time interval; in response to each renewal request, system topology information is generated according to the node identification information in the renewal request; after waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is completed, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information. With this method, when the central node takes over the distributed system, it receives the renewal request sent by the service node at a random value time interval, and reconstructs the system topology information according to the node identification information in the renewal request, thereby reducing the resource overhead of the central node, avoiding network storms when the central node reconstructs the topology information, and improving the stability of the central node topology maintenance.
[0085] In one embodiment, after step 201, the method further includes: recording, according to local boot clock information, the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request.
[0086] In implementation, the central node records the reception time of each service node's renewal request and the corresponding node identifier of the service node carried in the renewal request based on the local boot clock information, and records the timestamps of each service node's previous renewal requests.
[0087] In this embodiment, for the renewal request sent by the business node, the timestamp information carried in the renewal request sent by the business node is not used. Instead, the central node's own power-on clock system is used to record the time of the received renewal request to ensure the uniformity of the time information of each renewal request. At the same time, the continuity of the renewal request can be identified based on the record of the receiving time.
[0088] In one embodiment, Figure 3 As shown, after step 203, the method further includes:
[0089] Step 301: If no renewal request is received from a target service node within a preset time range threshold, it is determined that the target service node is faulty; the time threshold range is greater than or equal to the renewal period corresponding to the target service node.
[0090] In implementation, after the central node starts to provide services, for each service node included in the current system topology information, if no renewal request is received from the target service node (i.e., any node in the service node cluster) within a preset time range threshold, the central node determines that the target service node is faulty, where the time threshold range is greater than or equal to the renewal period corresponding to the target service node.
[0091] Step 302: Delete the target service node from the system topology information to obtain updated system topology information.
[0092] In implementation, the central node deletes the node identifier corresponding to the target service node in the system topology information to obtain updated system topology information.
[0093] Step 303, divide the business nodes in the business node cluster according to the preset business node number division mechanism, obtain the division results and the corresponding notification sequence information, and broadcast the updated system topology information in batches to other business nodes in the business node cluster except the target business node according to the division results and the corresponding notification sequence information, so as to instruct other business nodes to update the system topology information.
[0094] The target service node is a service node that is detected as faulty by the central node.
[0095] During implementation, the central node divides the business nodes in the business node cluster according to a preset business node number division mechanism (i.e., a preset division ratio) to obtain a division result and corresponding notification sequence information. For example, the 1,000 business nodes contained in the business node cluster can be divided into three batches (notified three times), the first batch includes business nodes 1 to business node 300, the second batch includes business nodes 301-600, and the third batch includes business nodes 601-1000. Then, the central node can broadcast the updated system topology information in batches to other business nodes in the business node cluster except the target business node (faulty business node) according to the business node division result and the corresponding notification sequence information (i.e., the corresponding batches), so as to instruct other business nodes to update the system topology information after deleting the target business node.
[0096] In this embodiment, the central node senses the failure of the service node by not receiving the renewal request of the target service node within a preset time range threshold, and then updates the system node topology information, and sends the updated system topology information to the service nodes in the service node cluster in multiple batches (i.e., in batches). Sending the system node topology information in batches multiple times reduces the processing burden of the central node and avoids network storms at the central node.
[0097] In one embodiment, Figure 4 As shown, after step 303, the method further includes:
[0098] Step 401, update the consistent hash ring of the service node cluster, transfer the hash ring interval corresponding to the faulty service node to the target service node in the service node cluster except the faulty service node, and add the faulty service node to the silent zone of the consistent hash ring.
[0099] Among them, the central node can perform interval mapping for the business nodes in the business node cluster according to the consistent hashing algorithm, specifically, taking the node identification information of each business node in the business node cluster (for example, the ID of the business node) as the input value, and obtaining an output value through consistent hashing calculation. The output value is mapped on the annular area of the hash ring, indicating that one business node corresponds to one annular interval. When the business request sent by the user also obtains a corresponding request output value through consistent hashing calculation, the consistent hashing ring is traversed according to the request output value. When the annular interval where the request output value is located is encountered, the business node corresponding to the annular interval is the business node that processes the business request.
[0100] In the implementation, the central node updates the consistent hash ring of the service node cluster, and transfers the hash ring interval corresponding to the faulty service node to the target service node other than the faulty service node in the service node cluster, that is, the hash ring interval corresponding to the faulty service node is transferred to the hash ring interval corresponding to the target service node adjacent to the faulty service node, and the faulty service node is added to the silent zone of the consistent hash ring, that is, the hash ring interval corresponding to the faulty service node is mapped to the silent zone of the hash ring. The silent zone of the hash ring is the interval corresponding to the service node that cannot respond to the service request.
[0101] Step 402: Receive a first service processing request sent by a client, and send the first service processing request to a corresponding processing node for processing.
[0102] In implementation, the central node receives a first business processing request (http request) sent by the client, and sends the first business processing request to a corresponding processing node (ie, business node) for processing according to a consistent hashing algorithm.
[0103] Step 403, if the processing node is a faulty business node, the node identifier of the processing node corresponding to the first business processing request is recalculated according to the consistent hashing algorithm, and the first business processing request is forwarded to the updated target business node according to the calculated node identifier to instruct the target business node to return processing failure information.
[0104] In implementation, if the central node calculates that the processing node id (identify) of the first business processing request corresponds to the faulty business node (that is, the hash ring interval corresponding to the first business processing request is the hash ring interval corresponding to the faulty business node), then after deleting the faulty business node in the system node topology information, it is necessary to update the consistent hash ring of the business node cluster, that is, add the faulty business node to the silent zone of the hash ring, and transfer the original hash ring interval corresponding to the faulty business node to the adjacent target business node, and then recalculate the node identifier of the processing node corresponding to the first business processing request according to the consistent hash algorithm, and forward the first business processing request to the updated target business node according to the calculated node identifier. When the faulty business node is in the silent zone of the hash ring, the new target business node only returns processing failure information for the first business node processing request. The specific reasons are as follows:
[0105] The failure type for the faulty service node may include a service node failure caused by a network outage. After the first service processing request is sent to the initial processing node (i.e., the service node with the current outage), the network of the faulty service node is restored and the service processing request can be processed. However, at the same time, since the central node perceives the outage of the initial processing node and has recalculated the target service processing node of the processing request according to the consistent hashing algorithm, a new target service processing node will appear to process the service request together with the faulty service node with the outage, causing a network storm caused by the concurrency of the service processing results. Therefore, when the faulty service node is still in the silent zone (i.e., not completely deleted in the hash ring), the target service processing node only returns the processing failure information for the service processing request received from the original processing node corresponding to the faulty service node. The processing failure information may be a specific error code.
[0106] Step 404, wait for a silent period and delete the faulty service node from the silent zone of the consistent hash ring; the silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring.
[0107] The silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring.
[0108] In implementation, the central node waits for a silent period and then removes the faulty service node from the silent zone of the consistent hash ring.
[0109] Step 405: Receive the second service processing request sent by the client, instruct the target service node to process the second service processing request, and return a processing success message to the client.
[0110] During implementation, the central node receives the second business processing request sent by the client, calculates the node identifier of the processing node corresponding to the second business processing request as the target business node based on the consistent hashing algorithm, then instructs the target business node to process the second business processing request, and returns a processing success message to the client.
[0111] Optionally, the second service processing request can be a processing request of the same type as the aforementioned first service processing request and corresponding to the same processing node, that is, the hash ring interval corresponding to the second service processing request is still the hash ring interval corresponding to the original faulty service node. However, at this time, the hash ring interval has been transferred to the mapping range of the target service processing node, and the corresponding faulty service node has been deleted in the hash silent area, then the target service node can process the second service processing request normally and return a successful processing message to the client.
[0112] In this embodiment, after the central node deletes the faulty service node, it waits for a silent period to avoid the faulty service node recalculating the new target service node determined by the processing node to process the service request together after receiving the first service processing request, thereby causing a network storm due to the concurrency of processing results, thereby improving the network stability of the distributed system.
[0113] In one embodiment, Figure 5 As shown, after step 203, the method further includes:
[0114] Step 501: Receive a new renewal request sent by a new service node.
[0115] In implementation, the central node receives a new renewal request sent by a new service node. The renewal request carries node identification information of the new service node, for example, the serial number of the node.
[0116] Step 502: In response to the new renewal request, update the system topology information according to the new renewal request.
[0117] In implementation, the central node responds to the new renewal request and updates the system node topology information according to the new renewal request. Specifically, the central node responds to the new renewal request and adds the node identification information of the new service node included in the new renewal request to the system node topology information to obtain the updated system node topology information.
[0118] Step 503, divide the business nodes in the business node cluster according to the preset business node number division mechanism, obtain the division results and the corresponding notification sequence information, and broadcast the updated system topology information in batches to each business node and the newly added business node in the business node cluster according to the division results and the corresponding notification sequence information, so as to instruct each business node and the newly added business node in the business node cluster to update the system topology information.
[0119] During implementation, the central node divides the business nodes in the business node cluster according to a preset business node number division mechanism (i.e., a preset division ratio), obtains the division results and the corresponding notification sequence information, and broadcasts the updated system topology information in batches to each business node in the business node cluster and the newly added business nodes according to the division results and the corresponding notification sequence information, so as to instruct each business node in the original business node cluster and the newly added business nodes to update the system topology information.
[0120] In this embodiment, the central node perceives the renewal request of the newly added business node, and then updates the system node topology information, and sends the updated system topology information to the business nodes in the business node cluster in multiple batches (i.e., in batches). Sending the system node topology information in batches multiple times reduces the processing burden of the central node and avoids network storms in the central node.
[0121] In one embodiment, Figure 6 As shown, after step 503, the method further includes:
[0122] Step 601, update the consistent hash ring of the business node cluster, and add the newly added business node to the silent zone of the consistent hash ring.
[0123] In implementation, after adding the newly added business node to the system topology information, the central node further updates the consistent hash ring of the business node cluster, that is, adds the newly added business node to the silent zone of the consistent hash.
[0124] Step 602, receiving the third business processing request sent by the client, calculating the processing node identifier corresponding to the third business processing request according to the consistent hashing algorithm, and sending the third business processing request to the corresponding processing node for processing according to the processing node identifier.
[0125] During implementation, the central node receives the third business processing request (http request) sent by the client, calculates the processing node identifier (processing node id) corresponding to the third business processing request according to the consistent hashing algorithm, and sends the third business processing request to the corresponding processing node for processing according to the processing node identifier.
[0126] Step 603: If the node is identified as a newly added service node, the newly added service node is instructed to return processing failure information.
[0127] In implementation, if the processing node is a newly added service node, since the newly added service node is still in the silent zone of the hash ring and needs to sleep for a silent period, the central node instructs the newly added service node to return processing failure information, where the processing failure information can be a specific error code.
[0128] Step 604, wait for a silent period until the newly added service node is in normal operation, receive the fourth service processing request sent by the client, instruct the newly added service node to process the fourth service processing request, and return a service processing success message to the client.
[0129] During implementation, the central node waits for a silent period until the newly added service node is in a normal operating state (also called a normal processing state) after successful renewal. When the central node receives the fourth service processing request sent by the client again, it can instruct the newly added service node to process the fourth service processing request and return a processing success message to the client. The processing success message can directly be the processing result of the corresponding service processing request.
[0130] In this embodiment, the central node first sleeps for a silent period for the newly added service node, and then implements the processing function of the newly added service node, which does not affect the operation of other service nodes. New service nodes are flexibly added in the distributed system, improving the flexibility of node topology maintenance in the distributed system.
[0131] In one embodiment, Figure 7 As shown, a system topology maintenance method is provided, which is applied to Figure 1 The service node 102 in FIG. 1 is used as an example to illustrate, including:
[0132] Step 701: at a time point generated by a preset random value time interval mechanism, a renewal request is sent to a central node, the renewal request carrying the node identification information of the service node itself; the random value time interval is less than a preset time threshold.
[0133] In implementation, a distributed system includes multiple service nodes, each of which sends a renewal request to a central node at a preset random value time interval as a renewal period, wherein the renewal request only carries the service node's own node identification information, for example, the node serial number information of the node. In addition, a service node that can send a renewal request within a preset time range is characterized as a service node that normally processes services.
[0134] Specifically, although the renewal period is determined in the form of a random value, the renewal period time value for each business node needs to be less than a preset time threshold, for example, a random value time interval within 1-7 seconds. Therefore, although it is a random value renewal period, the lease validity of each renewal request is still ensured, that is, after exceeding the preset time threshold, it can be determined that the renewal of the business node has failed, and the business node is a faulty business node that needs to be removed from the business node cluster.
[0135] Step 702: Receive system topology information sent by the central node, and update local topology information according to the system topology information.
[0136] In implementation, the service node receives the system topology information sent by the central node, and updates the local topology information according to the system topology information.
[0137] In this embodiment, the service nodes in the service node cluster send renewal requests to the central node at the time points generated by the random value time interval mechanism, thereby avoiding a situation where a large number of service nodes send renewal requests to the central node at the same time, causing a network storm in the central node, and improving the stability of the distributed system.
[0138] In one embodiment, if Figure 8 As shown, the specific processing process of step 702 is as follows:
[0139] Step 801: Receive system topology information sent by a central node, and compare the system topology information with local topology information of a service node.
[0140] In implementation, the service node receives the system topology information sent by the central node, and compares the system topology information with the local topology information of the service node.
[0141] Step 802: If the system topology information is inconsistent with the local topology information of the service node, the local topology information is updated according to the system topology information.
[0142] In implementation, if the system node topology information received by the service node is inconsistent with the node topology information stored locally in the service node, the local topology information of the service node is updated according to the received system topology information.
[0143] In this embodiment, by updating the service node topology information within the service node, it is avoided that the central node needs to determine whether each service node is updated, thereby reducing the processing pressure of the central node and avoiding network storms in the central node.
[0144] It should be understood that although Figure 2-8 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-8 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0145] In one embodiment, Fig. 9 As shown, an example of adding a new service node to a distributed system is provided. The specific process is as follows:
[0146] The newly added service node sends a renewal request to the central node; the central node adds the node identification information of the newly added node to the system node topology information. At the same time, the central node receives the renewal requests of each service node in the original service node cluster to complete the update of the system node topology information. Then, the central node sends a renewal success request to the newly added service node and each service node in the original service node cluster respectively and returns the updated system node topology information. The central node instructs the newly added service node to join the silent area of the consistent hash ring corresponding to the service node cluster, that is, the newly added service node sleeps for a silent period after the first renewal is successful. When the application sends an http request to the central node, if the processing node corresponding to the target processing node of the http request is the newly added service node, and the newly added service node is in the silent period at this time, then after the central node forwards the http request to the newly added service node, the newly added service node will return a specific error code to the application to prompt that the newly added service node is still in the silent period and cannot complete the service processing. When the silent period ends, the newly added service node is in a normal operating state with successful renewal, and the service processing mode is turned on. If an http request from an application is received at this time, and the target processing node corresponding to the http request is a newly added business node, the central node will forward the http request to the newly added business node, process it through the newly added business node, and then return the corresponding processing result to the application.
[0147] In one embodiment, Fig.10 As shown, an example of deleting a faulty service node in a distributed system is provided, and the specific process is as follows:
[0148] When the network status, node status and service process are all normal, if no renewal request is received from a certain service node within the preset time threshold, and the lease time of the previous renewal request of the service node has expired, the central node determines that the service node is a faulty service node. The central node deletes the faulty service node from the node topology information. At the same time, the central node receives renewal requests from other service nodes in the service node cluster to complete the update of the system node topology information. Then, the central node sends a renewal success message and updated system node topology information to other service nodes in the service node cluster except the faulty service node. The service node cluster recalculates the hash interval corresponding to the faulty service node and transfers it to another service node (called the target service node) according to the consistent hashing algorithm. The faulty service node is added to the silent zone of the hash ring and sleeps for a silent period. At this time, if the application sends an http request to the central node, the central node forwards the http request to the target business node based on the recalculation of the consistent hashing algorithm. The target business node determines that the original processing node of the http request should be the faulty business processing node, then it returns a specific error first, waits for a silent period, and when the faulty business node is deleted from the silent area of the hash ring, if the central business node receives the http request sent by the application again (the corresponding interval of the http request is the original mapping interval of the original faulty business node), the http request is forwarded to the target business node. At this time, the target business node can process the business request and return the corresponding processing result to the application.
[0149] In one embodiment, Fig.11 As shown, a system topology structure maintenance device 1100 is provided, comprising: a receiving module 1110, a generating module 1120 and a sending module 1130, wherein:
[0150] The receiving module 1110 is used to receive a renewal request from each service node, where the renewal request is sent by the service node according to a preset random value time interval;
[0151] A generating module 1120, configured to generate system topology information according to the node identification information in each renewal request in response to each renewal request;
[0152] The sending module 1130 is used to determine that the system topology reconstruction is complete after waiting for at least two consecutive renewal cycles, and send the system topology information to each renewed service node to instruct the service node to update the system topology information.
[0153] In one embodiment, the apparatus 1100 further includes:
[0154] The recording module is used to record the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request according to the local power-on clock information.
[0155] In one embodiment, the apparatus 1100 further includes:
[0156] A determination module, configured to determine that the target service node is faulty if no renewal request is received from the target service node within a preset time range threshold; the time threshold range is greater than or equal to the renewal period corresponding to the target service node;
[0157] An updating module, used for deleting a target service node in the system topology information to obtain updated system topology information;
[0158] The sending module is used to divide the business nodes in the business node cluster according to the preset business node number division mechanism, obtain the division results and the corresponding notification sequence information, and broadcast the updated system topology information in batches to other business nodes in the business node cluster except the target business node according to the division results and the corresponding sequence information, so as to instruct other business nodes to update the system topology information.
[0159] In one embodiment, the apparatus 1100 further includes:
[0160] An update module is used to update the consistent hash ring of the business node cluster, transfer the hash ring interval corresponding to the faulty business node to the target business node in the business node cluster except the faulty business node, and add the faulty business node to the silent zone of the consistent hash ring;
[0161] The transceiver module is used to receive a first service processing request sent by a client, and send the first service processing request to a corresponding processing node for processing;
[0162] A recalculation module, configured to recalculate the node identifier of the processing node corresponding to the first business processing request according to a consistent hashing algorithm if the processing node is a faulty business node, and forward the first business processing request to an updated target business node according to the calculated node identifier to instruct the target business node to return processing failure information;
[0163] A deletion module is used to wait for a silent period and delete the faulty service node from the silent zone of the consistent hash ring; the silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring;
[0164] The receiving module is used to receive the second service processing request sent by the client, to instruct the target service node to process the second service processing request, and to return a processing success message to the client.
[0165] In one embodiment, the apparatus 1100 further includes:
[0166] A receiving module, used to receive a new renewal request sent by a new service node;
[0167] A generating module, configured to respond to a new renewal request and update system topology information according to the new renewal request;
[0168] The sending module is used to divide the business nodes in the business node cluster according to the preset business node number division mechanism, obtain the division results and the corresponding notification sequence information, and broadcast the updated system topology information in batches to each business node and the newly added business node in the business node cluster according to the division results and the corresponding sequence information, so as to instruct each business node and the newly added business node in the business node cluster to update the system topology information.
[0169] In one embodiment, the apparatus 1100 further includes:
[0170] The update module is used to update the consistent hash ring of the business node cluster and add the new business node to the silent zone of the consistent hash ring;
[0171] A first transceiver module is used to receive a third business processing request sent by a client, calculate a processing node identifier corresponding to the third business processing request according to a consistent hash algorithm, and send the third business processing request to a corresponding processing node for processing according to the processing node identifier;
[0172] A judgment module, used for instructing the newly added service node to return processing failure information if the processing node is a newly added service node;
[0173] The second transceiver module is used to wait for a silent period until the newly added service node is in normal operation, receive the fourth service processing request sent by the client, instruct the newly added service node to process the fourth service processing request, and return a service processing success message to the client.
[0174] In one embodiment, Fig.12 As shown, a system topology maintenance device 1200 is provided, and the device 1200 includes:
[0175] The sending module 1210 is used to send a renewal request to the central node at a time point generated by a preset random value time interval mechanism, wherein the renewal request carries the node identification information of the service node itself; and the random value time interval is less than a preset time threshold;
[0176] The receiving module 1220 is used to receive the system topology information sent by the central node, and update the local topology information according to the system topology information.
[0177] In one embodiment, the receiving module 1220 is specifically used to receive the system topology information sent by the central node, and compare the system topology information with the local topology information of the service node;
[0178] If the system topology information is inconsistent with the local topology information of the service node, the local topology information is updated according to the system topology information.
[0179] The specific definition of the system topology structure maintenance device can be found in the definition of the system topology structure maintenance method above, which will not be repeated here. Each module in the above-mentioned system topology structure maintenance device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0180] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.13 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store system node topology data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a system topology structure maintenance method is implemented.
[0181] Those skilled in the art will understand that Fig.13 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0182] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0183] Receive a renewal request from each service node, where the renewal request is sent by the service node according to a preset random value time interval;
[0184] In response to each renewal request, generating system topology information according to the node identification information in the renewal request;
[0185] After waiting for at least two consecutive renewal cycles, it is determined that the system topology reconstruction is complete, and the system topology information is sent to each renewed service node to instruct the service node to update the system topology information.
[0186] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0187] According to the local power-on clock information, the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request are recorded.
[0188] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0189] If no renewal request is received from the target service node within a preset time range threshold, the target service node is determined to be faulty; the time threshold range is greater than or equal to the renewal period corresponding to the target service node;
[0190] Deleting the target service node in the system topology information to obtain updated system topology information;
[0191] The business nodes in the business node cluster are divided according to the preset business node number division mechanism to obtain the division results and the corresponding notification sequence information, and the updated system topology information is broadcast in batches to other business nodes in the business node cluster except the target business node according to the division results and the corresponding sequence information to instruct other business nodes to update the system topology information.
[0192] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0193] Update the consistent hash ring of the service node cluster, transfer the hash ring interval corresponding to the faulty service node to the target service node in the service node cluster except the faulty service node, and add the faulty service node to the silent zone of the consistent hash ring;
[0194] Receive a first service processing request sent by a client, and send the first service processing request to a corresponding processing node for processing;
[0195] If the processing node is a faulty service node, the node identifier of the processing node corresponding to the first service processing request is recalculated according to the consistent hashing algorithm, and the first service processing request is forwarded to the updated target service node according to the calculated node identifier to instruct the target service node to return processing failure information;
[0196] Wait for a silent period to delete the faulty service node from the silent zone of the consistent hash ring; the silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring;
[0197] The second service processing request sent by the client is received to instruct the target service node to process the second service processing request, and return a processing success message to the client.
[0198] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0199] Receive a new renewal request sent by a new service node;
[0200] In response to the new renewal request, updating the system topology information according to the new renewal request;
[0201] The business nodes in the business node cluster are divided according to the preset business node number division mechanism to obtain the division results and the corresponding notification sequence information, and the updated system topology information is broadcast in batches to each business node and the newly added business nodes in the business node cluster according to the division results and the corresponding sequence information to instruct each business node and the newly added business nodes in the business node cluster to update the system topology information.
[0202] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0203] Update the consistent hash ring of the business node cluster and add the newly added business nodes to the silent zone of the consistent hash ring;
[0204] Receive a third business processing request sent by the client, calculate a processing node identifier corresponding to the third business processing request according to a consistent hash algorithm, and send the third business processing request to a corresponding processing node for processing according to the processing node identifier;
[0205] If the processing node is a newly added service node, instruct the newly added service node to return processing failure information;
[0206] Wait for a silent period until the newly added service node is in a normal operating state, receive the fourth service processing request sent by the client, instruct the newly added service node to process the fourth service processing request, and return a service processing success message to the client.
[0207] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0208] At the time point generated by the preset random value time interval mechanism, a renewal request is sent to the central node, and the renewal request carries the node identification information of the service node itself; the random value time interval is less than the preset time threshold;
[0209] Receive the system topology information sent by the central node and update the local topology information according to the system topology information.
[0210] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0211] Receive system topology information sent by the central node, and compare the system topology information with the local topology information of the service node;
[0212] If the system topology information is inconsistent with the local topology information of the service node, the local topology information is updated according to the system topology information.
[0213] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0214] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0215] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0216] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A system topology maintenance method, characterized in that: The method comprises: receiving a renewal request from each service node, the renewal request being sent by the service node at a preset random value time interval, the random value being less than a preset time range threshold, to ensure the validity of each renewal request within the lease period; In response to each of the renewal requests, generating system topology information according to the node identification information in the renewal request; After waiting for at least two consecutive renewal cycles, determining that the system topology reconstruction is complete, and sending the system topology information to each renewed service node to instruct the service node to update the system topology information; The method further comprises: Updating the consistent hash ring of the service node cluster, transferring the hash ring interval corresponding to the faulty service node to a target service node other than the faulty service node in the service node cluster, and adding the faulty service node to the silent zone of the consistent hash ring; A first service processing request sent by a client is received, and the first service processing request is sent to a corresponding processing node for processing.
2. The method according to claim 1, characterized in that After receiving the renewal request from each service node, the method further includes: According to the local power-on clock information, the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request are recorded.
3. The method according to claim 1, characterized in that The method further comprises: If no renewal request of the target service node is received within a preset time range threshold, it is determined that the target service node is faulty; the time range threshold is greater than or equal to the renewal period corresponding to the target service node; Deleting the target service node in the system topology information to obtain updated system topology information; The business nodes in the business node cluster are divided according to a preset business node number division mechanism to obtain the division results and the corresponding notification sequence information, and the updated system topology information is broadcast in batches to other business nodes in the business node cluster except the target business node according to the division results and the corresponding sequence information to instruct the other business nodes to update the system topology information.
4. The method according to claim 1, characterized in that: The method further comprises: If the processing node is the faulty service node, recalculate the node identifier of the processing node corresponding to the first service processing request according to the consistent hashing algorithm, and forward the first service processing request to the updated target service node according to the calculated node identifier to instruct the target service node to return processing failure information; Waiting for a silent period, deleting the faulty service node from the silent zone of the consistent hash ring; the silent period is the sleep time of the faulty service node in the silent zone of the consistent hash ring; The second service processing request sent by the client is received to instruct the target service node to process the second service processing request, and return a processing success message to the client.
5. The method according to claim 1, characterized in that The method further comprises: Receive a new renewal request sent by a new service node; In response to the newly added renewal request, updating system topology information according to the newly added renewal request; The business nodes in the business node cluster are divided according to a preset business node number division mechanism to obtain division results and corresponding notification sequence information, and the updated system topology information is broadcast in batches to each business node in the business node cluster and the newly added business nodes according to the division results and the corresponding sequence information to instruct each business node in the business node cluster and the newly added business nodes to update the system topology information.
6. The method according to claim 5, characterized in that The method further comprises: Updating the consistent hash ring of the service node cluster, and adding the newly added service node to the silent zone of the consistent hash ring; Receive a third business processing request sent by the client, calculate a processing node identifier corresponding to the third business processing request according to a consistent hash algorithm, and send the third business processing request to a corresponding processing node for processing according to the processing node identifier; If the processing node is a newly added service node, instructing the newly added service node to return processing failure information; Waiting for a silent period until the newly added service node is in a normal operating state, receiving a fourth service processing request sent by the client, instructing the newly added service node to process the fourth service processing request, and returning the service processing success message to the client.
7. A system topology maintenance device, characterized in that: The device comprises: A receiving module, configured to receive a renewal request from each service node, wherein the renewal request is sent by the service node according to a preset random value time interval; the random value is less than a preset time range threshold to ensure the validity of each renewal request within the lease period; A generating module, configured to generate system topology information in response to each renewal request according to the node identification information in the renewal request; A sending module, used to determine that the system topology reconstruction is complete after waiting for at least two consecutive renewal cycles, and send the system topology information to each renewed service node to instruct the service node to update the system topology information; The device also includes: An update module, used to update the consistent hash ring of the service node cluster, transfer the hash ring interval corresponding to the faulty service node to a target service node in the service node cluster other than the faulty service node, and add the faulty service node to a silent zone of the consistent hash ring; The transceiver module is used to receive a first service processing request sent by a client, and send the first service processing request to a corresponding processing node for processing.
8. The device according to claim 7, characterized in that The device also includes: The recording module records the reception time of the renewal request of the service node and the node identifier of the service node corresponding to the renewal request according to the local power-on clock information.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
