Micro-service monitoring method and device, electronic equipment and storage medium
By using a combination of consistent hashing algorithm and virtual hash nodes in the microservice monitoring system, the problem of unbalanced monitoring load caused by the increase in the number of microservices is solved, and real-time collection and load balancing of monitoring data are achieved.
Patent Information
- Application Number
- CN202511927668.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-03
AI Technical Summary
As the number of microservices increases, existing technologies cannot guarantee the balance of monitoring load for microservices, resulting in uneven pressure on the monitoring system.
By using a consistent hashing algorithm to determine the target monitoring node for monitoring data within a hash ring composed of unique physical hash nodes and virtual hash nodes corresponding to each candidate monitoring node, the monitoring data is uploaded to the target node for monitoring, thus ensuring load balancing.
It enables real-time collection and timely processing of monitoring data, improves the load balancing of microservice monitoring nodes, and reduces the problem of system load imbalance.
Smart Images

Figure CN121597524A_ABST
Abstract
Description
Technical Field
[0001] This application relates to artificial intelligence technology, and more particularly to a microservice monitoring method, apparatus, electronic device, and storage medium. Background Technology
[0002] During production operations, the number of microservices will increase, making it crucial to promptly monitor service status and issue timely anomaly alerts.
[0003] In existing technologies, microservices and native monitoring services communicate via long-lived TCP connections. However, as the number of microservices increases, load balancing in monitoring cannot be guaranteed. Summary of the Invention
[0004] This application provides a microservice monitoring method, apparatus, electronic device, and storage medium to improve the load balancing of microservice monitoring nodes.
[0005] In a first aspect, embodiments of this application provide a microservice monitoring method, which includes:
[0006] By using the software development kits integrated into each client, monitoring data of each service to be monitored in the microservices can be obtained.
[0007] In a hash ring consisting of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, the target monitoring node corresponding to the monitoring data is determined based on the consistent hashing algorithm.
[0008] The monitoring data is uploaded to the target monitoring node to monitor each service to be monitored.
[0009] Secondly, embodiments of this application also provide a microservice monitoring device, which includes:
[0010] The monitoring data acquisition module is used to acquire monitoring data of each service to be monitored in the microservice through the software development kits integrated in each client.
[0011] The target monitoring node determination module is used to determine the target monitoring node corresponding to the monitoring data based on the consistent hashing algorithm in a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node.
[0012] The monitoring data upload module is used to upload monitoring data to the target monitoring node for monitoring of each service to be monitored.
[0013] Thirdly, embodiments of this application also provide an electronic device, which includes:
[0014] One or more processors;
[0015] Storage device for storing one or more programs;
[0016] When one or more programs are executed by one or more processors, the one or more processors implement any of the microservice monitoring methods provided in the embodiments of this application.
[0017] Fourthly, embodiments of this application also provide a storage medium including computer-executable instructions, which, when executed by a computer processor, are used to perform any of the microservice monitoring methods provided in embodiments of this application.
[0018] Fifthly, embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements any of the microservice monitoring methods provided in embodiments of this application.
[0019] This application utilizes software development kits integrated into each client to acquire monitoring data for each service to be monitored within a microservice, ensuring comprehensive, real-time, and low-intrusion monitoring information. Within a hash ring composed of unique physical hash nodes and at least one virtual hash node corresponding to each candidate monitoring node, a consistent hashing algorithm is used to determine the target monitoring node corresponding to the monitoring data. The consistent hashing algorithm and at least one virtual hash node ensure load balancing across candidate monitoring nodes. Monitoring data is then uploaded to the target monitoring node for monitoring of each service, ensuring real-time collection and timely processing of the monitoring data. Therefore, this technical solution addresses the problem of unbalanced monitoring load as the number of microservices increases, effectively improving the load balancing of monitoring nodes within microservices. Attached Figure Description
[0020] Figure 1 This is a flowchart of a microservice monitoring method according to Embodiment 1 of this application;
[0021] Figure 2 This is a flowchart of a microservice monitoring method according to Embodiment 2 of this application;
[0022] Figure 3 This is a schematic diagram of the structure of a microservice monitoring device according to Embodiment 3 of this application;
[0023] Figure 4 This is a schematic diagram of the structure of an electronic device according to Embodiment 4 of this application. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first" and "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] Example 1
[0027] Figure 1 This is a flowchart of a microservice monitoring method provided in Embodiment 1 of this application. This embodiment can be applied to the case of load balancing of monitoring nodes of microservices. The method can be executed by a microservice monitoring device, which can be implemented in software and / or hardware and applied to a microservice monitoring system.
[0028] See Figure 1 The microservice monitoring method shown includes the following steps:
[0029] S110. Obtain monitoring data for each service to be monitored in the microservices through the software development kits integrated in each client.
[0030] Software Development Kits (SDKs) are a set of development tools that provide a specific set of development tools for a particular software, hardware platform, or operating system, enabling developers to efficiently build applications. SSDs can be integrated into client-side applications, automatically collecting service call data and enabling comprehensive monitoring of the service's operational status on the client side.
[0031] Monitoring data can be packaged as information related to inter-service calls collected through a software development kit (SDK), used to monitor various microservices. For example, the collected monitoring data can include not only basic service call information, such as the provider application name, service name, and cluster name, but also key performance indicators such as the number of successful and failed calls. Furthermore, for more detailed analysis of service performance, the collected data can also include response times and exception information for each call; this application does not specifically limit this. Each service to be monitored can be a microservice application that requires monitoring.
[0032] Acquiring monitoring information through software development kits integrated into various clients offers advantages such as comprehensiveness, real-time performance, and low invasiveness. Comprehensiveness refers to covering all stages of service calls and providing rich monitoring dimensions. Real-time performance means data is collected instantly upon transaction occurrence, ensuring timely response from the monitoring system. Low invasiveness means that automatic data collection via software development kits reduces modifications to business code and lowers implementation difficulty.
[0033] S120. In a hash ring consisting of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, the target monitoring node corresponding to the monitoring data is determined based on the consistent hashing algorithm.
[0034] Consistent hashing is a special type of hashing algorithm used in distributed systems to handle data distribution and load balancing issues. It maps candidate monitoring nodes to a specific position on a ring through hash calculations, thus balancing the load across these nodes. Its core idea is to organize the entire hash value space into a ring-shaped structure, known as a hash ring (data range 0~2). 32 -1). Each candidate monitoring node is distributed on the hash ring based on its hash value (obtained by hashing its URL), and each monitoring data upload request is also mapped to a position on the ring based on its hash value (obtained by hashing the monitoring data in the same way). Candidate monitoring nodes can serve as a monitoring center within servers that process monitoring data for microservices, and can collect service call data statistics. The routing process for determining the target monitoring node for uploading monitoring data starts from the calculated hash value position and searches clockwise for the first node on the hash ring, which is then selected as the target monitoring node.
[0035] The hash ring consists of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node. Each physical hash node can correspond to multiple virtual hash nodes. These virtual hash nodes occupy different positions on the hash ring but actually point to the same physical hash node. The physical hash node can be the physical node corresponding to the candidate monitoring node in the hash ring. The virtual hash node can be the virtual node corresponding to the candidate monitoring node in the hash ring, used to balance the load of each candidate monitoring node. Virtual hash nodes can be mapped to their corresponding physical hash nodes, and then to their corresponding candidate monitoring nodes, through a mapping relationship. By adjusting the virtual hash nodes, even with a limited number of physical hash nodes, the distribution of the unique physical hash nodes corresponding to each candidate monitoring node on the hash ring can be made more even, thereby reducing hotspot phenomena and improving the system's load balancing performance.
[0036] S130. Upload the monitoring data to the target monitoring node to monitor each service to be monitored.
[0037] The upload process can be completed by calling the microservice governance framework. The microservice governance framework utilizes its efficient remote procedure call framework to ensure efficient and stable data transmission. Monitoring data can be uploaded periodically. The advantages of this periodic upload mechanism are: real-time guarantee, load optimization, and flexibility. Real-time guarantee means that data is updated once per upload cycle, ensuring the freshness of the monitoring system's data. Load optimization means that by reasonably scheduling the upload frequency, network congestion is avoided, ensuring the overall performance of the system. Flexibility means that the upload frequency can be adjusted according to actual needs, providing customized monitoring strategies for different scenarios.
[0038] Each candidate monitoring node is a monitoring service provider responsible for receiving and processing monitoring data from various application nodes. Specifically, each candidate monitoring node exposes a monitoring interface, which defines the methods for invoking remote procedure calls required for uploading monitoring data. Application clients then call these methods to report the collected monitoring data to the monitoring nodes.
[0039] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data comply with the relevant laws, regulations and standards of the relevant regions.
[0040] In a microservice architecture, the call relationships between services are complex, and traditional manual monitoring methods are no longer sufficient. During production operations, because microservices communicate with the native monitoring service via long-lived TCP connections, as the number of microservices increases, prolonged communication with multiple microservice clients consumes a significant amount of server resources. While the traditional solution of hashing groups based on service names can reduce the pressure to some extent, it still suffers from uneven pressure distribution among monitoring groups.
[0041] The technical solution of this embodiment obtains monitoring data of each service to be monitored in the microservices through the software development kits integrated in each client, ensuring that the obtained monitoring information is comprehensive, real-time, and low-intrusive. In a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, a consistent hashing algorithm is used to determine the target monitoring node corresponding to the monitoring data. The consistent hashing algorithm and at least one virtual hash node ensure the load balance of each candidate monitoring node. The monitoring data is uploaded to the target monitoring node to monitor each service to be monitored, ensuring real-time collection and timely processing of the monitoring data. Therefore, the technical solution of this application solves the problem of the inability to guarantee the load balance of monitoring as the number of microservices increases, achieving the effect of improving the load balance of monitoring nodes in microservices.
[0042] Example 2
[0043] Figure 2 This is a flowchart of a microservice monitoring method provided in Embodiment 2 of this application. The technical solution of this embodiment is further refined based on the above technical solution.
[0044] Furthermore, the phrase "in a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, the target monitoring node corresponding to the monitoring data is determined based on a consistent hashing algorithm" is refined as follows: "According to a preset hashing algorithm, the monitoring data is hashed to obtain the uploaded data hash; the uploaded data hash is mapped to the hash ring to determine the physical hash node or virtual hash node corresponding to the uploaded data hash; the candidate monitoring node corresponding to the physical hash node or virtual hash node corresponding to the uploaded data hash in the hash ring is taken as the target monitoring node" to determine the target monitoring node.
[0045] See Figure 2 The microservice monitoring method shown includes:
[0046] S210. Obtain monitoring data for each service to be monitored in the microservices through the software development kits integrated in each client.
[0047] S220. Perform hash calculation on the monitoring data according to the preset hash algorithm to obtain the hash of the uploaded data.
[0048] A preset hash algorithm is a pre-defined algorithm used to hash monitoring data to obtain the hash of the uploaded data. The uploaded data hash is the hash value obtained by hashing the monitoring data using the preset hash algorithm. Choosing a suitable hash algorithm is crucial for achieving load balancing. An ideal preset hash algorithm should have good uniform distribution characteristics to ensure that the distribution of detection nodes on the hash ring is as even as possible.
[0049] In one optional embodiment, the default consistent hashing algorithm is a 32-bit cyclic redundancy check algorithm.
[0050] The 32-bit Cyclic Redundancy Check (CR) algorithm is a hash algorithm based on polynomial division. Its core is to treat the data as a binary polynomial and perform a modulo-2 division operation with a preset generator polynomial to obtain a 32-bit check value, which is beneficial for achieving load balancing of monitoring nodes.
[0051] By employing a 32-bit cyclic redundancy check algorithm, the load balance of each candidate monitoring node can be guaranteed.
[0052] S230. Map the uploaded data hash to the hash ring and determine the physical hash node or virtual hash node corresponding to the uploaded data hash.
[0053] The position of the uploaded data hash in the hash ring, which consists of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, is determined based on the hash of the uploaded data. The first physical hash node or virtual hash node is found in a clockwise direction and is used as the physical hash node or virtual hash node corresponding to the hash of the uploaded data.
[0054] S240. Select the candidate monitoring node corresponding to the physical hash node or virtual hash node in the hash ring corresponding to the uploaded data hash as the target monitoring node.
[0055] If the uploaded data hash corresponds to a physical hash node in the hash ring, then the candidate monitoring node corresponding to the physical hash node is used as the target monitoring node. If the uploaded data hash corresponds to a virtual hash node in the hash ring, then the virtual hash node is mapped to the corresponding physical hash node, and the candidate monitoring node corresponding to the physical hash node is used as the target monitoring node. For example, mapping a virtual hash node to a corresponding physical hash node can be done by finding the first physical hash node in a clockwise direction and using it as the physical hash node for mapping the virtual hash node.
[0056] In an optional embodiment, the hash ring, consisting of the unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, is determined as follows: based on the load capacity of each candidate monitoring node, the number of virtual nodes corresponding to each candidate monitoring node is determined, and the corresponding number of virtual hash nodes are added in the counterclockwise direction of the unique physical hash node corresponding to each candidate monitoring node to form a hash ring.
[0057] Load capacity can be determined based on factors such as the cache capacity and interface speed of each candidate monitoring node. Since the load capacity of each candidate monitoring node may differ, a completely uniform distribution could lead to load mismatch. Therefore, it is necessary to adjust the load of the physical hash nodes corresponding to each candidate monitoring node through virtual hash nodes.
[0058] For example, the number of virtual nodes can be determined based on the ratio of the load capacity of each candidate monitoring node to achieve load capacity matching. For instance, if there are 3 candidate monitoring nodes with load capacities of 3:2:1, the corresponding number of virtual nodes can be determined to be 2, 1, and 0, respectively. This ensures that after the virtual hash nodes and the physical hash nodes corresponding to each candidate monitoring node are evenly distributed, the monitoring requests loaded by the physical hash nodes corresponding to each candidate monitoring node are proportional to their corresponding load capacity.
[0059] The load range corresponding to each candidate monitoring node in the hash ring is the range of hash values corresponding to the arc from the counterclockwise direction to the next monitoring node. Therefore, when the load capacity of a monitoring node is strong, multiple virtual nodes can be added to its physical node in the counterclockwise direction. In this way, after all physical hash nodes and virtual hash nodes are evenly distributed in the hash ring, the candidate monitoring node with strong load capacity actually carries more monitoring upload requests, thus achieving load capacity matching.
[0060] By determining the number of virtual nodes corresponding to each candidate monitoring node based on the load capacity of each candidate monitoring node, and adding the corresponding number of virtual hash nodes in the counterclockwise direction of the unique physical hash node corresponding to each candidate monitoring node to form a hash ring, it is ensured that the monitoring requests of each candidate monitoring node are proportional to its corresponding load capacity, thereby achieving the matching of the load requests received by each candidate monitoring node with its load capacity.
[0061] In an optional embodiment, the method further includes: if a new candidate monitoring node is detected, or a candidate monitoring node exits, then an updated hash ring is formed based on the updated candidate monitoring nodes, and the updated hash ring is sent to each client.
[0062] If a new candidate monitoring service node is detected, or a candidate monitoring service node exits, it is necessary to recalculate the hash value of each candidate monitoring node and map it onto a hash ring to ensure a uniform distribution of candidate monitoring nodes and thus ensure the balanced load of subsequent candidate monitoring. For example, hash calculations can be performed based on the updated URLs of each candidate monitoring node to obtain updated hash values. Based on these hash values, each candidate monitoring node is mapped onto a hash ring to obtain an updated hash ring. This updated hash ring is then sent to each client so that the integrated software development kits in each client can determine the target monitoring node for uploading monitoring data. The hash calculation algorithm used is the preset hash algorithm used for hash calculations of monitoring data.
[0063] If a new candidate monitoring node is detected, or a candidate monitoring node exits, an updated hash ring is formed based on the updated candidate monitoring nodes, and the updated hash ring is sent to each client. This allows for timely responses to the increase or decrease of candidate monitoring nodes, timely adjustments to the distribution of each candidate monitoring node in the hash ring, ensuring a balanced distribution of each candidate monitoring node, and improving the reliability of the hash ring.
[0064] In an optional embodiment, after detecting a new candidate monitoring node or a candidate monitoring node exiting, and then re-forming an updated hash ring based on the updated candidate monitoring nodes and sending the updated hash ring to each client, the embodiment further includes: if a candidate monitoring node is detected to have applied to exit, then persistently storing the data in the candidate monitoring node that applied to exit.
[0065] If a candidate monitoring service node requests to exit, the data in that node must be persistently stored to ensure data reliability and prevent data loss. For example, when a candidate monitoring service node requests to exit, all data from that node is stored persistently in a designated database. After all data is persistently stored, the candidate monitoring node is deleted, ensuring data reliability.
[0066] S250. Upload the monitoring data to the target monitoring node to monitor each service to be monitored.
[0067] The technical solution of this embodiment calculates the hash of the uploaded data by performing a hash calculation on the monitoring data according to a preset hash algorithm; maps the uploaded data hash to a hash ring to determine the target monitoring node corresponding to the uploaded data hash; the preset hash algorithm ensures the uniform distribution of the monitoring data in the hash ring; and the uniform distribution of each candidate monitoring node in the hash ring ensures the load balance of each monitoring node.
[0068] Example 3
[0069] Figure 3 The diagram shown is a structural schematic of a microservice monitoring device provided in Embodiment 3 of this application. This embodiment is applicable to load balancing of monitoring nodes for microservices. The specific structure of the microservice monitoring device is as follows:
[0070] The monitoring data acquisition module 310 is used to acquire monitoring data of each service to be monitored in the microservice through the software development kit integrated in each client.
[0071] The target monitoring node determination module 320 is used to determine the target monitoring node corresponding to the monitoring data based on the consistent hashing algorithm in a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node.
[0072] The monitoring data upload module 330 is used to upload monitoring data to the target monitoring node in order to monitor each service to be monitored.
[0073] The technical solution of this embodiment obtains monitoring data of each service to be monitored in the microservices through the software development kits integrated in each client, ensuring that the obtained monitoring information is comprehensive, real-time, and low-intrusive. In a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, a consistent hashing algorithm is used to determine the target monitoring node corresponding to the monitoring data. The consistent hashing algorithm and at least one virtual hash node ensure the load balance of each candidate monitoring node. The monitoring data is uploaded to the target monitoring node to monitor each service to be monitored, ensuring real-time collection and timely processing of the monitoring data. Therefore, the technical solution of this application solves the problem of the inability to guarantee the load balance of monitoring as the number of microservices increases, achieving the effect of improving the load balance of monitoring nodes in microservices.
[0074] Optionally, the hash ring, consisting of the unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, is determined in the following way:
[0075] Based on the load capacity of each candidate monitoring node, the number of virtual nodes corresponding to each candidate monitoring node is determined, and the corresponding number of virtual hash nodes are added in the counterclockwise direction of the unique physical hash node corresponding to each candidate monitoring node to form a hash ring.
[0076] Optionally, the target monitoring node determination module 320 includes:
[0077] The upload data hashing unit is used to perform hash calculations on the monitoring data according to a preset hash algorithm to obtain the upload data hash.
[0078] The upload data hash mapping unit is used to map the upload data hash to the hash ring and determine the physical hash node or virtual hash node corresponding to the upload data hash.
[0079] The target monitoring node determination unit is used to select the candidate monitoring nodes corresponding to the physical hash node or virtual hash node in the hash ring of the uploaded data as the target monitoring nodes.
[0080] Optionally, the microservice monitoring appliance also includes:
[0081] The hash ring update module is used to regenerate an updated hash ring based on the updated candidate monitoring nodes if a new candidate monitoring node is detected or a candidate monitoring node exits, and then send the updated hash ring to each client.
[0082] Optionally, the microservice monitoring appliance also includes:
[0083] The exit node data storage module is used to persistently store the data in the candidate monitoring node that requests to exit if a candidate monitoring node is detected to be requesting to exit.
[0084] Optionally, the default consistent hashing algorithm is a 32-bit cyclic redundancy check algorithm.
[0085] The microservice monitoring device provided in this application embodiment can execute the microservice monitoring method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the microservice monitoring method.
[0086] According to embodiments of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.
[0087] Example 4
[0088] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of this application, as shown below. Figure 4 As shown, the electronic device includes a processor 410, a memory 420, an input device 430, and an output device 440; the number of processors 410 in the electronic device can be one or more. Figure 4 Taking a processor 410 as an example; the processor 410, memory 420, input device 430, and output device 440 in the electronic device can be connected via a bus or other means. Figure 4 Taking the example of a connection between China and Israel via a bus.
[0089] The memory 420, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the microservice monitoring method in this embodiment (e.g., monitoring data acquisition module 310, target monitoring node determination module 320, and monitoring data upload module 330). The processor 410 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 420, thereby implementing the aforementioned microservice monitoring method.
[0090] The memory 420 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 420 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 420 may further include memory remotely located relative to the processor 410, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0091] Input device 430 can be used to receive input character information and generate key signal inputs related to user settings and function control of the electronic device. Output device 440 may include display devices such as a display screen.
[0092] Example 5
[0093] Embodiment 5 of this application also provides a storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are used to execute a microservice monitoring method. The method includes: obtaining monitoring data of each service to be monitored in the microservice through a software development kit integrated in each client; determining the target monitoring node corresponding to the monitoring data based on a consistent hashing algorithm in a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node; and uploading the monitoring data to the target monitoring node to monitor each service to be monitored.
[0094] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the method operations described above, but can also execute related operations in the microservice monitoring method provided in any embodiment of this application.
[0095] Based on the above description of the implementation methods, those skilled in the art can clearly understand that this application can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0096] It is worth noting that in the embodiments of the microservice monitoring device described above, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of this application.
[0097] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the appended claims.
Claims
1. A microservice monitoring method, characterized in that, include: By using the software development kits integrated into each client, monitoring data of each service to be monitored in the microservices can be obtained. In a hash ring consisting of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, the target monitoring node corresponding to the monitoring data is determined based on the consistent hashing algorithm. The monitoring data is uploaded to the target monitoring node to monitor each of the services to be monitored.
2. The method according to claim 1, characterized in that, The hash ring, consisting of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node, is determined in the following manner: Based on the load capacity of each candidate monitoring node, the number of virtual nodes corresponding to each candidate monitoring node is determined, and the corresponding number of virtual hash nodes are added in the counterclockwise direction of the unique physical hash node corresponding to each candidate monitoring node to form a hash ring.
3. The method according to claim 1, characterized in that, The step of determining the target monitoring node corresponding to the monitoring data based on a consistent hashing algorithm within a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node includes: The monitoring data is hashed according to a preset hash algorithm to obtain the uploaded data hash. The uploaded data hash is mapped to a hash ring to determine the physical hash node or virtual hash node corresponding to the uploaded data hash; The candidate monitoring node corresponding to the physical hash node or virtual hash node in the hash ring of the uploaded data is taken as the target monitoring node.
4. The method according to claim 1, characterized in that, The method further includes: If a new candidate monitoring node is detected, or a candidate monitoring node exits, an updated hash ring is formed based on the updated candidate monitoring nodes, and the updated hash ring is sent to each client.
5. The method according to claim 4, characterized in that, After the step of detecting a new candidate monitoring node or a candidate monitoring node exiting the test, re-forming an updated hash ring based on the updated candidate monitoring nodes, and sending the updated hash ring to each client, the method further includes: If a candidate monitoring node is detected to be requesting to exit, the data in the candidate monitoring node requesting to exit will be persistently stored.
6. The method according to claim 3, characterized in that, The preset consistent hash algorithm is a 32-bit cyclic redundancy check algorithm.
7. A microservice monitoring device, characterized in that, include: The monitoring data acquisition module is used to acquire monitoring data of each service to be monitored in the microservice through the software development kits integrated in each client. The target monitoring node determination module is used to determine the target monitoring node corresponding to the monitoring data based on the consistent hashing algorithm in a hash ring composed of a unique physical hash node corresponding to each candidate monitoring node and at least one virtual hash node corresponding to each candidate monitoring node. The monitoring data upload module is used to upload the monitoring data to the target monitoring node in order to monitor each of the services to be monitored.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the microservice monitoring method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the microservice monitoring method as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the microservice monitoring method as described in any one of claims 1-6.