Method for realizing micro-service application resource index data statistics

By constructing the metric statistics container MetricBucket and using the WindowRecord class, the problems of unstable performance and abnormal monitoring of data in microservice architecture applications are solved, real-time and efficient statistics and monitoring of microservice application resource indicator data are realized, and system performance and decision-making accuracy are improved.

CN119557175APending Publication Date: 2025-03-04INSPUR SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411497262.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In the cloud computing environment, there are problems such as unstable performance and abnormal monitoring data during the operation of microservice architecture applications, and the system performance monitoring and real-time feedback of system status are not effective.

Method used

By constructing the MetricBucket metric statistics container, the storage of performance metric data is realized, and the rapid accumulation and statistics of metric data is realized by configuring the sampling period and time window. Use the WindowRecord class to record time window information, quickly locate and process indicator data, and reduce memory usage and GC pressure.

Benefits of technology

Real-time and efficient collection, monitoring and statistics of microservice application resource indicator data, improve the accuracy and real-time nature of system performance monitoring, and provide a data basis for optimizing system configuration and evaluating service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557175A_ABST
    Figure CN119557175A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing micro-service application resource index data statistics, which belongs to the technical field of cloud computing and micro-service application governance, and is characterized in that the storage of performance index data is realized by constructing an index statistics container Metri Buck, and the rapid accumulation and statistics of the index data are realized by configuring a sampling period and a time window. According to the invention, real-time and efficient acquisition, monitoring and statistics of various operation index data can be realized, real-time monitoring of system performance and monitoring system state can be realized, and a data basis is provided for optimizing system configuration, evaluating service quality and guiding decision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing and microservice application governance, and in particular to a method for realizing microservice application resource indicator data statistics. Background Art

[0002] In the existing technology, in the cloud computing environment, there are problems such as unstable performance and abnormal monitoring data during the operation of microservice architecture applications, and the system performance monitoring and real-time feedback of system status are not good. Summary of the invention

[0003] The technical task of the present invention is to address the above shortcomings and provide a method for realizing statistics of microservice application resource indicator data, which can realize real-time and efficient collection, monitoring and statistics of various operation indicator data, realize real-time monitoring of system performance and monitoring system status, and provide data basis for optimizing system configuration, evaluating service quality and guiding decision-making.

[0004] The technical solution adopted by the present invention to solve its technical problem is:

[0005] A method for realizing the statistics of microservice application resource indicator data, storing performance indicator data by constructing an indicator statistics container MetricBucket, and realizing the rapid accumulation and statistics of indicator data by configuring the sampling period and time window.

[0006] Furthermore, the configuration time window enables accurate and rapid positioning of the MetricBucket.

[0007] Furthermore, a WindowRecord class is constructed to record the start timestamp and size of each time window. Through data indexing, it is quickly determined whether there is a WindowRecord in the current time window, and the original WindowRecord is quickly constructed or overwritten according to the actual situation. The index data is stored through array recycling, which greatly reduces the memory usage of the system, avoids manual processing of expired statistics, and reduces the pressure on GC.

[0008] Furthermore, the construction indicator statistics container is as follows:

[0009] Construct a MetricBucket as a storage container for various QPS indicator data within a period of time. Here you can define its information, including: total number of storage requests, total number of exceptions, total time consumption, minimum time consumption, etc.; define a private array variable counters, and put the total number of requests, total number of exceptions, and total time consumption information in the LongAdder array, [LongAdder (total number of successful statistical requests), LongAdder (total number of statistical request exceptions), LongAdder (total statistical time consumption)]. At this stage, the LongAdder array is used to ensure the atomicity of data modification and have better performance;

[0010] The time period of the MetricBucket that records the indicator data can be customized, which can be 1 millisecond or 1 second. This period is the time window size of each Bucket. During this time period, each successful request, request exception, and total request time information can obtain the corresponding LongAdder instance for accumulation.

[0011] Furthermore, the configuration time window is as follows:

[0012] The time period of each MetricBucket is a sliding window, which is defined according to actual business needs:

[0013] If you need to monitor the second-level QPS data of a certain interface, you only need to set the size of the sliding window to 1 second. Similarly, if you want to count the QPS data of a certain second in the last minute, you need to set the size of the sliding window to 1 minute and the sampling rate to 60. In this way, 60 MetricBuckets will be built in a sliding window, recording the QPS data of each second in the current minute. Developers can obtain and locate the Bucket by timestamp as required.

[0014] If you need to continuously obtain all MetricBucket data within 1 minute, the simple method of traversing the array from beginning to end is no longer suitable. You need to determine the timestamps of the start and end segments, and then calculate the MetricBucket array index of the start timestamp. In each loop, increase the start timestamp by 1 second until the start timestamp and the end timestamp are the same.

[0015] The sliding window will slide forward over time, so the array in the MetricBucket will be written cyclically. The current timestamp and the timestamps one minute before and after will be mapped to the same MetricBucket. Therefore, each element in the array needs to store the start timestamp of the MetricBucket time window and the size of the time window to determine whether the current timestamp is within the acquired MetricBucket time window.

[0016] Since MetricBucket mainly stores indicator data and does not save time window information itself, it is necessary to construct a time window class WindowRecord to record time window information, including the size of the MetricBucket time window, the timestamp of the start of the sliding window, and the MetricBucket information itself.

[0017] Furthermore, the MetricBucket positioning method is as follows:

[0018] A WindowRecord array is a sliding window;

[0019] When a request is received, an index value can be calculated based on the timestamp when the request is received and the size of the sliding window, and a WindowRecord class can be obtained from the sliding window (WindowRecord array), thereby obtaining the MetricBucket wrapped by the WindowRecord class, and calling the add method of the MetricBucket instance to count the indicators;

[0020] The index (cidx) of the MetricBucket of the current time window in the array is calculated using the current timestamp, as well as the start timestamp of the Bucket's time window, and the historical MetricBucket is obtained from the array using the index.

[0021] Furthermore, the specific implementation steps of the MetricBucket positioning method are as follows:

[0022] First, determine whether a MetricBucket exists in the current index. If not, create a new MetricBucket and return the instance.

[0023] If the current index can locate a historical MetricBucket and the timestamp is consistent with the new MetricBucket, the instance is returned directly;

[0024] If the new MetricBucket time window is calculated to be later than the historical MetricBucket timestamp stored in the current index, the historical MetricBucket can be reused and returned after a secure reset.

[0025] When the calculated new MetricBucket time window is earlier than the historical MetricBucket timestamp, an empty MetricBucket is returned directly because time does not go backwards.

[0026] Furthermore, the method to obtain the previous MetricBucket of the current timestamp is as follows:

[0027] If the start timestamp of the time window of the current MetricBucket is calculated based on the current timestamp, then the start timestamp of the previous MetricBucket can be located by subtracting the time window size of the MetricBucket from the start timestamp of the time window of the current MetricBucket. Since the sliding window is implemented using an array data structure, each element of the array will be used cyclically, so there may be a gap of a complete sliding window period between the current MetricBucket and the previous MetricBucket.

[0028] Compare the current timestamp with the start timestamp of the MetricBucket's time window. If it spans a sliding window period, it means that this MetricBucket does not meet the requirements, and continue to look for the next MetricBucket that meets the conditions.

[0029] The present invention also claims a device for realizing statistics of microservice application resource indicator data, comprising: at least one memory and at least one processor;

[0030] The at least one memory is used to store a machine-readable program;

[0031] The at least one processor is used to call the machine-readable program to implement the above method.

[0032] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which implement the above method when executed by a processor.

[0033] Compared with the prior art, the method for realizing microservice application resource indicator data statistics of the present invention has the following beneficial effects:

[0034] 1. Real-time monitoring: The sliding window can reflect the usage of system resources in real time, helping developers and operation and maintenance personnel to promptly discover and resolve system resource bottlenecks and abnormal situations, optimize system configuration, and improve the overall performance and stability of microservice applications.

[0035] 2. Improve monitoring accuracy: The sliding window can accurately record and count various resource indicator data, reflect the real-time status and performance of the system, and help decision makers make accurate decisions.

[0036] 3. Enhanced scalability: The real-time indicator data statistics method based on sliding windows can be extended to more resource indicator data types and more application scenarios, such as distributed systems, cloud computing, etc., and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a schematic diagram of locating a MetricBucket in an array provided by an embodiment of the present invention;

[0038] Figure 2 It is a schematic diagram of a MetricBucket for locating a previous cycle provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The present invention will be further described below in conjunction with specific embodiments.

[0040] The embodiment of the present invention provides a method for realizing the statistics of microservice application resource indicator data, which realizes the storage of performance indicator data by constructing an indicator statistics container MetricBucket, and realizes the rapid accumulation and statistics of indicator data by configuring the sampling period and time window.

[0041] The configuration time window enables accurate and rapid positioning of the MetricBucket.

[0042] Construct the WindowRecord class to record the start timestamp and size of each time window, and quickly determine whether there is a WindowRecord in the current time window through data index, and quickly build or overwrite the original WindowRecord according to the actual situation. By recycling the array and storing indicator data, the system's memory usage is greatly reduced, while avoiding manual processing of expired statistics and alleviating GC pressure.

[0043] Through the statistical and acquisition method of indicator data, we can quickly understand the system performance and monitor the system status, which is of great significance for optimizing system configuration, evaluating service quality and guiding decision-making.

[0044] Microservices is a software architecture style that splits an application into a series of small, independent services, each of which runs in its own process and communicates through lightweight communication mechanisms. Each service has clear business capabilities and can be independently developed, deployed, and expanded. The goal of microservice architecture is to improve the scalability, flexibility, and maintainability of the system while reducing the risk of single point failure. The core characteristics of microservice architecture are distributed, decentralized, self-contained, and modular. It emphasizes splitting an application into multiple independent services, each of which is responsible for handling specific business functions and can be independently developed, tested, deployed, and expanded. The communication between microservices is based on lightweight communication mechanisms such as HTTP protocol or message queues to achieve loose coupling between services.

[0045] A time window is a way to define a time period on a timeline, and is often used in planning, scheduling, and forecasting. In microservices, time windows are often used for current limiting and flow control to protect system resources and maintain system stability and reliability. Time windows can be used to describe the completion time of a given task, or to describe the requirement that a specific task be completed within a given time period. In microservices, time windows are often used for current limiting and flow control to protect system resources and maintain system stability and reliability. By using a sliding window algorithm, traffic can be dynamically adjusted based on the system's processing power and resource limitations, ensuring that the system can efficiently process requests and maintain stable operation.

[0046] Microservice resource indicator data refers to various indicators that monitor the resource usage of microservice application systems, including but not limited to:

[0047] CPU Usage: Monitor CPU usage and assess system load levels.

[0048] Memory usage: Monitor memory usage and evaluate whether system memory resources are sufficient.

[0049] Network bandwidth: Monitor network bandwidth usage and assess network load levels.

[0050] I / O operation times: Monitors the number of disk I / O operations and evaluates disk read and write speed and load.

[0051] Request response time: Monitor request response time to evaluate system responsiveness and service performance.

[0052] Error rate: Monitor error rate and evaluate system stability and service quality.

[0053] Number of connections: Monitor the number of concurrent connections and evaluate the system's concurrent capabilities and connection management.

[0054] TCP connection status: Monitor the TCP connection status and evaluate the stability and performance of the system network connection.

[0055] Number of threads: Monitor the number of threads to evaluate system processing capabilities and thread management.

[0056] System Load: Monitor system load to assess system processing power and resource usage.

[0057] The following takes the QPS indicator as an example to analyze the implementation process of the related indicator data statistics method based on the sliding window.

[0058] Step 1: Construct an indicator statistics container.

[0059] Construct a MetricBucket as a storage container for various QPS indicator data within a period of time. Here you can define the total number of requests, total number of exceptions, total time consumption, minimum time consumption, etc. By defining a private array variable counters, the total number of requests, total number of exceptions, and total time consumption information are placed in the LongAdder array, [LongAdder (total number of successful statistical requests), LongAdder (total number of statistical request exceptions), LongAdder (total statistical time consumption)]. At this stage, the LongAdder array is used to ensure the atomicity of data modification and has better performance.

[0060] The time period of the MetricBucket that records the metric data can be customized, which can be 1 millisecond or 1 second. This period is the time window size of each Bucket. During this time period, each successful request, request exception, and total request time information can obtain the corresponding LongAdder instance for accumulation.

[0061] Step 2: Configure the time window.

[0062] As mentioned in step 1, the time period of each MetricBucket is a sliding window, which can be defined according to our actual business needs.

[0063] If you need to monitor the second-level QPS data of a certain interface, you only need to set the window size to 1 second. Similarly, if you want to count the QPS data of a certain second in the last minute, you need to set the sliding window to 1 minute and the sampling rate to 60; in this way, 60 MetricBuckets will be built in a sliding window, recording the QPS data of every second in the current minute; developers can obtain and locate the Bucket by timestamp as needed.

[0064] If you need to continuously obtain all MetricBucket data within 1 minute, the simple method of traversing the array from beginning to end is no longer appropriate. You need to determine the timestamps of the start and end segments, and then calculate the MetricBucket array index of the start timestamp. In each loop, increase the start timestamp by 1 second until the start timestamp and the end timestamp are the same.

[0065] The sliding window will slide forward over time, so the array in the MetricBucket will be written cyclically. The current timestamp and the timestamps one minute before and after will be mapped to the same MetricBucket. Therefore, each element in the array needs to store the start timestamp of the MetricBucket's time window and the size of the time window to determine whether the current timestamp is within the acquired MetricBucket time window.

[0066] Since MetricBucket mainly stores indicator data and does not save time window information itself, it is necessary to construct a time window class WindowRecord to record time window information, including the size of the MetricBucket time window, the timestamp of the start of the sliding window, and the MetricBucket information itself.

[0067] Step 3: The MetricBucket location method is as follows:

[0068] As mentioned above, MetricBucket is used to count various indicator data, and the WindowRecord class is used to record time window information (including the start timestamp and size of the time window), and a WindowRecord array is a sliding window.

[0069] When a request is received, an index value can be calculated based on the timestamp when the request is received and the sliding window size, and a WindowRecord class can be obtained from the sliding window (WindowRecord array), thereby obtaining the MetricBucket wrapped by the WindowRecord class, and calling the add method of the MetricBucket instance to count the indicators.

[0070] The index (cidx) of the MetricBucket of the current time window in the array is calculated using the current timestamp, as well as the start timestamp of the Bucket's time window, and the historical MetricBucket is obtained from the array using the index.

[0071] The steps to locate the MetricBucket are as follows:

[0072] (1) First, determine whether a MetricBucket exists in the current index. If not, create a new MetricBucket and return the instance.

[0073] (2) If the current index can locate a historical MetricBucket and the timestamp is consistent with the new MetricBucket, the instance is returned directly;

[0074] (3) If the new MetricBucket time window is calculated to be later than the historical MetricBucket timestamp stored in the current index, the historical MetricBucket can be reused and returned after a secure reset process;

[0075] (4) When the calculated new MetricBucket time window is earlier than the historical MetricBucket timestamp, an empty MetricBucket is directly returned because time does not go backwards.

[0076] The method to get the previous MetricBucket of the current timestamp is as follows:

[0077] If the start timestamp of the time window of the current MetricBucket is calculated based on the current timestamp, then the start timestamp of the previous MetricBucket can be located by subtracting the time window size of the MetricBucket from the start timestamp of the time window of the current MetricBucket. Since the sliding window is implemented using an array data structure, each element of the array will be used cyclically, so there may be a gap of a complete sliding window period between the current MetricBucket and the previous MetricBucket.

[0078] like Figure 2As shown. The time window start timestamp of the MetricBucket calculated based on the current timestamp is 1595974702000. In order to find the time window start timestamp of the previous MetricBucket, we need to subtract the time window size of the MetricBucket from the current timestamp. However, since the sliding window adopts a circular array data structure in its implementation, there may be a gap of a complete sliding window cycle between the current MetricBucket and the previous MetricBucket. Therefore, we need to compare the current timestamp with the time window start timestamp of the MetricBucket. If it spans a sliding window cycle, it means that this MetricBucket is not what we want. In this case, we need to continue to look for the next MetricBucket that meets the conditions.

[0079] This method provides a fine-grained indicator statistics method to solve the problems of unstable performance and abnormal monitoring data during the operation of microservice architecture applications, and realizes the statistics and analysis of the total number of requests (totalRequest), the total number of successful processing (totalSuccessResponse), the total number of failures (totalfailedResponse), the total time taken (totalTimeTaken), the average time taken (averageTimeTaken), the maximum time taken (maximumTimeTaken), the minimum time taken (minimumTimeTaken), and the total number of rejected requests (totalRejectedRequests) in the current time window of each resource. Relying on the sliding window technology, the array is recycled to store indicator data, which greatly reduces the memory usage of the system, avoids the manual processing of expired statistics, and relieves the pressure of GC. Relying on this method, it is of great significance for developers to understand system performance, monitor system status, optimize system configuration, evaluate service quality, and guide decision-making.

[0080] The embodiment of the present invention also provides a device for implementing microservice application resource indicator data statistics, including: at least one memory and at least one processor;

[0081] The at least one memory is used to store a machine-readable program;

[0082] The at least one processor is used to call the machine-readable program to implement the method for realizing microservice application resource indicator data statistics described in the above embodiment.

[0083] The embodiment of the present invention also provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by the processor, the method for realizing the statistics of microservice application resource indicator data described in the above embodiment can be implemented. Specifically, a system or device equipped with a storage medium can be provided, on which the software program code that realizes the functions of any of the above embodiments is stored, and the computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.

[0084] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0085] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0086] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0087] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0088] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A method for realizing microservice application resource indicator data statistics, characterized in that: The performance indicator data can be stored by constructing the indicator statistics container MetricBucket, and the indicator data can be quickly accumulated and counted by configuring the sampling period and time window.

2. A method for realizing microservice application resource indicator data statistics according to claim 1, characterized in that: The configuration time window enables accurate and rapid positioning of the MetricBucket.

3. A method for realizing microservice application resource indicator data statistics according to claim 1 or 2, characterized in that: Construct the WindowRecord class to record the start timestamp and size of each time window, and quickly determine whether there is a WindowRecord in the current time window through data index, and quickly build or overwrite the original WindowRecord according to the actual situation.

4. A method for realizing microservice application resource indicator data statistics according to claim 1, characterized in that: The construction indicator statistics container is as follows: Construct a MetricBucket as a storage container for various QPS indicator data within a period of time, and define its information, including: total number of storage requests, total number of exceptions, total time consumption, and minimum time consumption; define a private array variable counters, and put the total number of requests, total number of exceptions, and total time consumption information in the LongAdder array, [LongAdder (total number of successful statistical requests), LongAdder (total number of statistical request exceptions), LongAdder (total statistical time consumption)]. At this stage, the LongAdder array is used to ensure the atomicity of data modification; The time period of the MetricBucket that records the indicator data can be customized. This period is the time window size of each Bucket. During this time period, each successful request, abnormal request, and total request time information is accumulated by obtaining the corresponding LongAdder instance.

5. A method for realizing microservice application resource indicator data statistics according to claim 1 or 4, characterized in that: The configuration time window is as follows: The time period of each MetricBucket is a sliding window, which is defined according to actual business needs: If you need to monitor the second-level QPS data of a certain interface, set the sliding window size to 1 second. If you want to count the QPS data of a certain second in the last minute, you need to set the sliding window size to 1 minute and the sampling rate to 60. In this way, 60 MetricBuckets will be built in a sliding window, recording the QPS data of each second in the current minute. Developers can obtain and locate the Bucket by timestamp as required. If you need to continuously obtain all MetricBucket data within 1 minute, you need to determine the timestamps of the start and end periods, and then calculate the MetricBucket array index of the start timestamp. In each loop, increase the start timestamp by 1 second until the start timestamp and the end timestamp are the same. Each element in the array stores the start timestamp of the MetricBucket's time window and the size of the time window, so as to determine whether the current timestamp is within the acquired MetricBucket's time window; A time window class WindowRecord is constructed to record the time window information, including the size of the MetricBucket time window, the timestamp of the start of the sliding window, and the MetricBucket information itself.

6. A method for realizing microservice application resource indicator data statistics according to claim 5, characterized in that: The MetricBucket positioning method is as follows: A WindowRecord array is a sliding window; When a request is received, an index value is calculated based on the timestamp of the request and the size of the sliding window, a WindowRecord class is obtained from the sliding window, and the MetricBucket wrapped by the WindowRecord class is obtained. The add method of the MetricBucket instance is called to collect statistics. Calculate the index of the MetricBucket of the current time window in the array and the start timestamp of the Bucket's time window using the current timestamp, and get the historical MetricBucket from the array using the index.

7. A method for realizing microservice application resource indicator data statistics according to claim 6, characterized in that: The specific implementation steps of the MetricBucket positioning method are as follows: First, determine whether a MetricBucket exists in the current index. If not, create a new MetricBucket and return the instance. If the current index can locate a historical MetricBucket and the timestamp is consistent with the new MetricBucket, the instance is returned directly; If the new MetricBucket time window is calculated to be later than the historical MetricBucket timestamp stored in the current index, the historical MetricBucket is reused and returned after a secure reset. When the calculated new MetricBucket time window is earlier than the historical MetricBucket timestamp, an empty MetricBucket is returned directly.

8. A method for realizing microservice application resource indicator data statistics according to claim 7, characterized in that: The method to get the previous MetricBucket of the current timestamp is as follows: If the start timestamp of the time window of the current MetricBucket is calculated based on the current timestamp, then the start timestamp of the previous MetricBucket can be located by subtracting the time window size of the MetricBucket from the start timestamp of the time window of the current MetricBucket. Compare the current timestamp with the start timestamp of the MetricBucket's time window. If it spans a sliding window period, it means that this MetricBucket does not meet the conditions, and continue to look for the next MetricBucket that meets the conditions.

9. A device for realizing statistics of microservice application resource indicator data, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to implement the method according to any one of claims 1 to 8.

10. A computer-readable medium, characterized in that The computer readable medium stores computer instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 8.