Interface pressure testing method and apparatus
By dynamically calculating the Poisson rate through real-time acquisition of system status data and generating a test request interval sequence, the problem of insufficient system status adaptation in traditional stress testing methods is solved, realizing adaptive interface stress testing and improving the realism and security of the test.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
- Filing Date
- 2026-03-20
- Publication Date
- 2026-06-12
Smart Images

Figure CN122195844A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to an interface stress testing method and apparatus. Background Technology
[0002] Currently, traditional stress testing often uses a fixed Poisson rate to generate request flows, but this method has significant drawbacks. A fixed request rate cannot respond to changes in the real-time state of the system (such as a surge in response latency, an increase in error rate, or CPU / memory resource overload), leading to a disconnect between the test scenario and real user behavior. It cannot simulate the "retreat" effect of real users abandoning requests due to system lag, and it is also easy to skip probing the system's critical performance states due to improper request rate settings, resulting in a significant amount of testing time being wasted on invalid load intervals (invalid stress testing often accounts for more than 30%). At the same time, mechanically injecting high loads may trigger unnecessary service avalanche risks.
[0003] Therefore, how to dynamically adapt to system states for interface stress testing and improve the authenticity, effectiveness and security of the tests has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of the above problems, the present invention provides an interface stress testing method and apparatus that overcomes or at least partially solves the above problems, the technical solution of which is as follows:
[0005] An interface stress testing method, comprising:
[0006] Obtain the operating status data of the system under test at the current moment;
[0007] Based on the operating status data and the preset performance target, the dynamic adjustment factor at the current moment is obtained;
[0008] The target dynamic Poisson rate at the current moment is determined using the dynamic adjustment factor and the preset benchmark Poisson rate.
[0009] Generate a test request interval sequence according to the target dynamic Poisson rate;
[0010] Send interface stress test requests to the system under test according to the test request interval sequence;
[0011] Receive the response result of the interface stress test request.
[0012] Optionally, after receiving the response result of the interface stress test request, the method further includes:
[0013] Update the running status data based on the response result, return to the step of obtaining the dynamic adjustment factor at the current moment based on the running status data and the preset performance target, so as to perform the next round of dynamic adjustment of Poisson's rate.
[0014] Optionally, obtaining the dynamic adjustment factor at the current moment based on the operating status data and the preset performance target includes:
[0015] Using the operating status data and the preset target response time, the integral-derivative adjustment term of the system under test at the current moment is obtained;
[0016] Using the running status data and the preset error rate threshold, the error rate constraint and resource constraint at the current moment are obtained.
[0017] Optionally, obtaining the integral-derivative adjustment term of the system under test at the current moment using the operating status data and the preset target response time includes:
[0018] The error term at the current moment is obtained by using the real-time response time and the preset target response time in the operation status data;
[0019] The dynamic integral weight at the current moment is obtained by using the error term at the current moment and the real-time error rate in the running status data.
[0020] The error integral term at the current moment is obtained by using the error term at the current moment, the error term at the previous moment, and the error integral term at the previous moment.
[0021] The dynamic differential weight at the current moment is obtained by using the rate of change between the error term at the current moment and the error term at the previous moment.
[0022] The error differential term at the current moment is obtained by using the difference between the error term at the current moment and the error term at the previous moment;
[0023] Using the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term at the current moment, the integral-differential adjustment term of the system under test at the current moment is obtained.
[0024] Optionally, obtaining the error rate constraint and resource constraint at the current moment using the running status data and a preset error rate threshold includes:
[0025] Using the real-time error rate and the preset error rate threshold in the running status data, the error rate constraint term at the current moment is obtained;
[0026] By utilizing the CPU utilization and memory utilization in the running status data, the resource constraints at the current moment are obtained.
[0027] Optionally, obtaining the integral-derivative adjustment term of the system under test at the current moment using the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term includes:
[0028] Input the current error term, dynamic integral weight, error integral term, dynamic derivative weight, and error derivative term into the formula:
[0029] ;
[0030] Obtain the integral-derivative adjustment term, where, Indicates the current time; This is the integral-differential adjustment term; This refers to the error term at the current moment; The dynamic integral weight at the current moment; This is the integral term of the error at the current moment; The dynamic differential weight at the current moment; This is the differential term of the error at the current moment.
[0031] Optionally, determining the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and the preset benchmark Poisson rate includes:
[0032] Input the preset benchmark Poisson ratio, the integral-derivative adjustment term, the error rate constraint term, and the resource constraint term into the formula:
[0033] ;
[0034] Obtain the target dynamic Poisson rate at the current moment, where, The target dynamic Poisson's ratio; The preset reference Poisson's ratio; This is the integral-differential adjustment term; For the error rate constraint term; This refers to the resource constraint.
[0035] Optionally, before generating the test request interval sequence according to the target dynamic Poisson rate, the method further includes:
[0036] Determine whether the running status data meets the preset circuit breaker trigger condition. If not, execute the step of generating a test request interval sequence according to the target dynamic Poisson rate. If yes, follow a progressive recovery strategy to gradually restore the target dynamic Poisson rate from one proportion of the preset benchmark Poisson rate to another proportion over multiple consecutive time periods until the running status data no longer meets the preset circuit breaker trigger condition.
[0037] Optionally, the gradual recovery strategy includes:
[0038] During the first recovery period, the target dynamic Poisson rate is set to a first proportion of the preset benchmark Poisson rate, and only specific types of requests are restricted from being sent.
[0039] During the second recovery period, the target dynamic Poisson rate is set to a second proportion of the preset benchmark Poisson rate, and core service requests are allowed to be sent, wherein the second proportion is greater than the first proportion;
[0040] During the third recovery period, the target dynamic Poisson rate is set to a third proportion of the preset benchmark Poisson rate, and non-core business requests are allowed to be sent, wherein the third proportion is greater than the second proportion.
[0041] An interface stress testing device includes: a running status data acquisition unit, a dynamic adjustment factor acquisition unit, a target dynamic Poisson rate determination unit, a test request interval sequence generation unit, an interface stress test request sending unit, and a response result receiving unit.
[0042] The operating status data acquisition unit is used to acquire the operating status data of the system under test at the current moment;
[0043] The dynamic adjustment factor acquisition unit is used to obtain the dynamic adjustment factor at the current moment based on the operating status data and the preset performance target.
[0044] The target dynamic Poisson rate determination unit is used to determine the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and the preset benchmark Poisson rate.
[0045] The test request interval sequence generation unit is used to generate a test request interval sequence according to the target dynamic Poisson rate;
[0046] The interface stress test request sending unit is used to send interface stress test requests to the system under test according to the test request interval sequence.
[0047] The response result receiving unit is used to receive the response result of the interface stress test request.
[0048] By employing the above technical solution, this invention provides an interface stress testing method and apparatus that obtains the operating status data of the system under test at the current moment; based on the operating status data and a preset performance target, obtains the dynamic adjustment factor at the current moment; uses the dynamic adjustment factor and a preset benchmark Poisson rate to determine the target dynamic Poisson rate at the current moment; generates a test request interval sequence according to the target dynamic Poisson rate; sends interface stress test requests to the system under test according to the test request interval sequence; and receives the response results of the interface stress test requests. This invention dynamically calculates and adjusts the Poisson rate based on the real-time response results and resource status of the system under test, enabling the test pressure to adaptively increase or decrease with system performance, thereby automatically simulating the behavioral changes of real users when facing system lag, accurately detecting the system's critical state, and avoiding invalid or overloaded testing, ultimately comprehensively improving the authenticity, effectiveness, and security of the test.
[0049] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0050] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0051] Figure 1 A flowchart illustrating one embodiment of the interface stress testing method provided by this invention is shown.
[0052] Figure 2 The diagram shows a specific implementation of step S110 in the interface stress testing method provided by the present invention.
[0053] Figure 3 A schematic diagram of the interface stress testing device provided in an embodiment of the present invention is shown;
[0054] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention is shown. Detailed Implementation
[0055] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0056] In stress testing of modern software systems, especially distributed microservice architectures, simulating realistic and dynamic user access traffic is crucial for evaluating system performance and stability. The Poisson process, due to its ability to effectively describe the random arrival characteristics of user requests, is often used to generate request flows for stress testing; that is, it uses a fixed Poisson rate (…). The parameter controls the frequency of request sending.
[0057] However, this traditional stress testing method based on a fixed Poisson's ratio has significant limitations. In real-world production environments, user behavior and system state are tightly coupled and dynamically changing. For example, when the system response slows down, some users may give up waiting or reduce their operation frequency; when system resources (such as CPU and memory) are overutilized, their processing capacity decreases, and the actual request rate they can handle also decreases. A fixed request rate cannot respond to such real-time changes in system state, leading to a disconnect between the test scenario and real-world conditions, mainly manifested in the following ways:
[0058] 1. Poor scenario realism: The test traffic is mechanically and continuously injected, which cannot simulate the "give up" or "retreat" behavior of real users when they encounter system lag (high latency) or increased error rate. This makes it difficult for the test results to accurately reflect the system's performance and user experience under real load.
[0059] 2. Low testing efficiency: A fixed request rate may cause the testing process to remain in a non-critical state of the system for a long time (such as stable operation under low load), or the system may be overwhelmed instantly due to an improperly set request rate (too high), thus skipping the exploration of critical states such as system performance inflection points and elastic scaling capabilities. This results in a large amount of testing time being spent on invalid or non-critical load intervals. According to statistics, invalid load tests usually account for more than 30%.
[0060] 3. Resource waste and risk: The inability to adaptively limit the rate based on system resource usage (such as CPU overload) may cause unnecessary service avalanches or resource exhaustion during testing, affecting the stability of the tested system and even related systems, which contradicts the principle of "controllable and observable" stress testing.
[0061] Based on this, this invention provides an interface stress testing method. This method collects real-time operating status data of the system under test and dynamically calculates adjustment factors based on preset performance targets. These factors, along with a benchmark Poisson's ratio, determine the target dynamic Poisson's ratio. A test request interval is then generated, stress test requests are sent to the system, and response results are received to update the status data, enabling the next round of adaptive adjustment. This invention dynamically adjusts the stress based on the actual system performance, accurately simulating user behavior during system lag, precisely identifying critical system states, effectively avoiding invalid or overloaded testing, and significantly improving the realism, effectiveness, and security of the test.
[0062] like Figure 1 The diagram shows a flowchart of one embodiment of the interface stress testing method provided by this invention. The method may include:
[0063] S100: Obtain the operating status data of the system under test at the current moment.
[0064] The system under test refers to the target system for interface stress testing, which can be a server or application that provides services.
[0065] Among them, the operational status data refers to the indicator data that reflects the current operational status of the system under test.
[0066] Optionally, runtime status data may include real-time response time. Real-time error rate ), CPU utilization ( ) and memory usage ( ).
[0067] Specifically, embodiments of the present invention can use a configured monitoring platform to retrieve multi-dimensional real-time status indicators of the system under test at a preset acquisition frequency. These multi-dimensional real-time status indicators include at least real-time response time, real-time error rate, CPU utilization, and memory utilization. The collected multi-dimensional real-time status indicators are preprocessed to obtain preprocessed operational status data. For example, embodiments of the present invention can perform outlier detection on the data in the multi-dimensional real-time status indicators and replace the detected outliers with a moving average; the outlier-processed data is then smoothed using an exponential moving average, normalizing the smoothed data to the [0,1] interval.
[0068] As examples, embodiments of the present invention can use the monitoring system Prometheus to collect the real-time response time, real-time error rate, CPU utilization, and memory utilization of the system under test at a frequency of 100ms. The collected raw data is immediately preprocessed: first, outliers are identified and replaced using the Z-score method; then, the data is smoothed using the exponential moving average method to eliminate jitter; finally, all indicators are normalized to the [0,1] interval to eliminate dimensional differences, forming a standardized real-time status dataset that can be used for calculation, i.e., runtime status data.
[0069] S110. Based on the operating status data and preset performance targets, obtain the dynamic adjustment factor at the current moment.
[0070] Among them, the preset performance target refers to the performance indicator standard used during testing, such as the target response time ( ), Maximum allowable error rate ( (e.g., ) are used to guide the dynamic adjustment of request pressure to meet business needs.
[0071] The dynamic adjustment factor refers to the adjustment coefficient calculated based on the current operating status data and preset performance targets. It is used to dynamically adjust the request rate of the stress test and mainly includes the integral-derivative adjustment term (…). Error rate constraint () ) and resource constraints ( ).
[0072] Specifically, embodiments of the present invention can obtain the dynamic adjustment factor at the current moment based on operating status data and preset performance targets by calculating the integral-derivative control term driven by response time error and combining it with the protective constraint term composed of system error rate and resource utilization rate.
[0073] S120. Using the dynamic adjustment factor and the preset benchmark Poisson rate, determine the target dynamic Poisson rate at the current moment.
[0074] Among them, the preset benchmark Poisson ratio ( This refers to the base request rate configured by the user based on the daily peak traffic of the interface, which serves as a benchmark for dynamic adjustment and can be set to approximately 80% of the peak QPS.
[0075] Among them, the target dynamic Poisson's law ( The current request rate, adjusted by a dynamic factor, determines the actual sending rate of stress test requests and reflects the system status in real time.
[0076] Specifically, in this embodiment of the invention, the target dynamic Poisson rate at the current moment can be determined by combining multiple sub-items included in the dynamic adjustment factor with the preset benchmark Poisson rate.
[0077] S130. Generate a test request interval sequence according to the target dynamic Poisson rate.
[0078] Among them, the test request interval sequence refers to a continuous request time interval sequence generated by the Poisson distribution (exponential distribution) based on the target dynamic Poisson rate, used to simulate the randomness of real user requests.
[0079] Specifically, embodiments of the present invention can simulate request arrival intervals through a Poisson process based on the currently calculated target dynamic Poisson rate. For example, embodiments of the present invention can use a computing library (such as NumPy) to generate a random number sequence following an exponential distribution, where the rate parameter of the exponential distribution is the target dynamic Poisson rate. Each random number x represents a request interval (in seconds), calculated as x = np.random.exponential(1 / ).
[0080] S140. Send interface stress test requests to the system under test according to the test request interval sequence.
[0081] Among them, interface stress test requests refer to test requests sent to the system under test in a sequence of test request intervals to apply stress and trigger system responses in order to evaluate its performance and stability.
[0082] Specifically, in this embodiment of the invention, the load testing engine can send interface requests to the system under test sequentially at set time intervals based on the generated request intervals. For different business scenarios, different types of request parameters or request methods may be carried, and the response results of each request are recorded, including response time and success status, to ensure the integrity of data collection.
[0083] As examples, embodiments of the present invention strictly follow the test request interval sequence generated in the previous step through the worker nodes of the load testing engine Locust, continuously and stably sending HTTP / HTTPS requests to the target interface (such as the order submission API) of the system under test at calculated time intervals. These requests simulate real user behavior and record timestamps when sent, in preparation for subsequent calculation of response time.
[0084] S150, Receive the response result of the interface stress test request.
[0085] The response result refers to the feedback information returned by the system under test to the interface stress test requests sent during the stress test, which may include response time, request status, request result, and error rate.
[0086] Specifically, in this embodiment of the invention, the load testing engine can be used to collect response data of all requests in real time, summarize them and send them to the monitoring system or directly to the control module for analysis.
[0087] As examples, embodiments of the present invention can utilize a stress testing engine to receive and record the response results of each request, wherein the response results may include a response status code, response content, and response time RT. The present invention provides an interface stress testing method, which includes: obtaining the operating status data of the system under test at the current moment; obtaining a dynamic adjustment factor at the current moment based on the operating status data and a preset performance target; determining the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and a preset benchmark Poisson rate; generating a test request interval sequence according to the target dynamic Poisson rate; sending interface stress test requests to the system under test according to the test request interval sequence; and receiving the response results of the interface stress test requests. The present invention dynamically calculates and adjusts the Poisson rate based on the real-time response results and resource status of the system under test, enabling the test pressure to adaptively increase or decrease with system performance, thereby automatically simulating the behavioral changes of real users when facing system lag, accurately detecting the system's critical state, and avoiding invalid or overloaded testing, ultimately comprehensively improving the authenticity, effectiveness, and security of the test.
[0088] Optionally, in the above Figure 1 Based on one or more corresponding embodiments, in another optional embodiment provided by the present invention, after step S150, the method may further include:
[0089] Update the running status data based on the response results, return to the execution step of obtaining the dynamic adjustment factor at the current moment based on the running status data and preset performance targets, so as to carry out the next round of Poisson rate dynamic adjustment.
[0090] Specifically, embodiments of the present invention can update operational status data based on the latest response time, error rate, and other indicators, providing input for the next round of dynamic adjustment factor calculation. The entire process forms a closed-loop feedback, continuously adjusting the dynamic Poisson's law to achieve adaptive stress testing, ensuring the accuracy and safety of the testing process.
[0091] As examples, the response results are aggregated and fed back to the monitoring system (such as Prometheus), thereby updating metrics such as real-time response time and real-time error rate in the "Operating Status Data". After the update, the process immediately jumps back to step S110 to begin a new round of adjustment factor calculation based on the latest status data, thus forming a closed-loop control loop of "monitoring-decision-pressure-feedback" to achieve complete pressure adaptation.
[0092] Optional, based on Figure 1 The method shown is as follows: Figure 2 The diagram shows a specific implementation of step S110 in the interface stress testing method provided by this invention. Step S110 may include:
[0093] S200. Using the operating status data and the preset target response time, obtain the integral-derivative adjustment term of the system under test at the current moment.
[0094] The embodiments of the present invention can utilize operating status data and preset target response time to obtain the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term of the tested system at the current moment.
[0095] Among them, the preset target response time ( This refers to the upper limit of the interface response time preset according to the service level agreement or performance requirements of the system under test. The preset target response time is used to measure the interface performance target and serves as a benchmark for dynamically adjusting request pressure.
[0096] Among them, the error term ( The error term refers to the difference between the actual response time of the interface at the current moment and the preset target response time. The error term reflects the degree to which the system's current response performance deviates from the target; a positive value indicates that the response time is better than the target, and a negative value indicates that the response time exceeds the target.
[0097] Among them, dynamic integral weight ( This refers to the dynamic adjustment coefficient used to weight the error integral term, which takes into account the response time deviation rate during calculation. ) and error rate normalization ( The range of values for the dynamic integral weights can be limited to [0.01, 0.5], with the aim of smoothing the impact of the integral term on the dynamic adjustment.
[0098] Among them, the error integral term ( This refers to the integral of historical errors, reflecting the accumulation trend of errors over time, and is used to adjust the long-term stress test rate. The calculation takes into account the error trend and decay mechanism.
[0099] Among them, dynamic differential weights ( This refers to the dynamic coefficient weighted on the error differential term, reflecting the magnitude of the impact of the rate of change of response time on the adjustment strategy. The calculation is based on the rate of change of response time. The value range of the dynamic differential weight can be limited to [0.005, 0.3].
[0100] Among them, the error differential term ( This refers to the rate of change of error between the current time and the previous time, with smoothing to buffer transient fluctuations.
[0101] Specifically, in this embodiment of the invention, the response time error term at the current moment can be calculated based on the running status data and the preset target response time. Based on the error term and its relationship with the real-time error rate and historical error data, the weights of integral and derivative control and the corresponding error integral and error derivative terms can be dynamically determined respectively.
[0102] The embodiments of the present invention can utilize the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term at the current moment to obtain the integral-differential adjustment term of the system under test at the current moment.
[0103] Among them, the integral-derivative adjustment term ( This refers to a comprehensive adjustment factor based on the error term, error integral term, error differential term, and their dynamic weights, used to correct the benchmark Poisson's ratio. This enables intelligent adjustment of the request sending rate.
[0104] Specifically, in this embodiment of the invention, the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term at the current moment can be input into the formula:
[0105] ;
[0106] Obtain the integral-derivative adjustment term, where, Indicates the current time; For integral-differential adjustment terms; This represents the error term at the current moment; This represents the dynamic integral weight at the current moment; This is the integral term of the error at the current moment; The dynamic differential weight at the current moment; This is the differential term of the error at the current moment.
[0107] S210. Using the running status data and the preset error rate threshold, obtain the error rate constraint and resource constraint at the current moment.
[0108] Among them, the preset error rate threshold ( This refers to the maximum allowed interface error rate threshold, usually expressed as a percentage (e.g., 0.05 means a maximum allowed error rate of 5%). The preset error rate threshold is used to calculate error rate constraints, simulating user tolerance for erroneous requests and their tendency to abandon them.
[0109] Among them, the error rate constraint term ( () refers to a constraint factor used to limit the growth of request pressure and prevent excessive error rates from causing system overload or deteriorating user experience.
[0110] Among them, resource constraints ( This refers to a protective constraint factor generated based on system resource utilization to prevent test pressure from exceeding the system's carrying capacity.
[0111] Specifically, in this embodiment of the invention, the error rate constraint and resource constraint at the current moment can be obtained by calculating the deviation of the real-time error rate and resource utilization from their respective security boundaries based on the running status data and the preset error rate threshold.
[0112] Based on operational status data and preset performance targets, this invention dynamically and comprehensively calculates error terms and adjusts them using integral and differential methods. By combining error rate and resource usage constraints, it achieves precise adaptive adjustment of system pressure, ensuring that the test load closely matches actual performance requirements while effectively preventing system overload and improving the accuracy and safety of stress testing.
[0113] Optionally, in the above Figure 2 Based on one or more corresponding embodiments, in another optional embodiment provided by the present invention, step S120 may include:
[0114] The target dynamic Poisson rate at the current moment is obtained by using the preset benchmark Poisson rate, integral-derivative adjustment term, error rate constraint term, and resource constraint term.
[0115] Specifically, in this embodiment of the invention, a preset benchmark Poisson rate, integral-derivative adjustment term, error rate constraint term, and resource constraint term can be input into the formula:
[0116] ;
[0117] Obtain the target dynamic Poisson rate at the current moment, where, The target dynamic Poisson's law; The preset benchmark Poisson's ratio; For integral-differential adjustment terms; For error rate constraints; This is a resource constraint.
[0118] This invention, based on the integral-derivative adjustment term in the dynamic adjustment factor and the error rate and resource constraints, effectively combines a preset benchmark Poisson rate to achieve accurate calculation of the target dynamic Poisson rate, ensuring that the request generation rate meets both performance targets and system stability, thereby improving the adaptability and security of stress testing.
[0119] Optionally, in the above Figure 2 Based on one or more corresponding embodiments, in another optional embodiment provided by the present invention, the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term of the system under test at the current moment are obtained using running status data and a preset target response time. Specifically, this may include:
[0120] By using the real-time response time and the preset target response time in the running status data, the error term at the current moment can be obtained.
[0121] Specifically, in this embodiment of the invention, the real-time response time and the preset target response time in the running status data can be input into the formula:
[0122] ,
[0123] Obtain the error term at the current time, where, This is the error term; For real-time response time; The preset target response time.
[0124] The dynamic integral weight for the current moment is obtained by using the error term at the current moment and the real-time error rate in the running status data.
[0125] Specifically, in this embodiment of the invention, the error term at the current moment and the real-time error rate in the running status data can be input into the formula:
[0126] ,
[0127] ,
[0128] ,
[0129] Obtain the dynamic integral weight at the current moment, where, For dynamic integral weights; The response time deviation rate represents the relative deviation of the response time. This is the error rate normalization value, representing the normalization of the current error rate relative to the threshold.
[0130] The error integral term at the current moment is obtained by using the error term at the current moment, the error term at the previous moment, and the error integral term at the previous moment.
[0131] Specifically, in this embodiment of the invention, the error term from the previous time step, the error term from the previous time step, and the integral term of the error from the previous time step can be input into the formula:
[0132] ,
[0133] Obtain the integral term of the error at the current time, where, For a moment The error integral term; For a moment The error integral term; For a moment Error term; For a moment Error term; The time interval can be 0.1; When the error sign reverses, a smaller value (e.g., 0.5) is taken to achieve dynamic decay of the integral term and prevent integral overshoot; limiting conditions are set. This is to avoid the integral term being too large, which could lead to uncontrolled adjustment.
[0134] The dynamic differential weight at the current moment is obtained by using the rate of change between the error term at the current moment and the error term at the previous moment.
[0135] Specifically, in this embodiment of the invention, the rate of change between the error term at the current moment and the error term at the previous moment can be input into the formula:
[0136] ,
[0137] ,
[0138] Obtain the dynamic differential weights at the current moment, where, For dynamic differential weights; This represents the rate of change of the real-time response time error; For a moment Error term; For a moment Error term.
[0139] The error differential term at the current moment is obtained by using the difference between the error term at the current moment and the error term at the previous moment.
[0140] Specifically, in this embodiment of the invention, the error term at the current moment and the error term at the previous moment can be input into the formula:
[0141] ,
[0142] Obtain the differential term of the error at the current moment, where, This is the error differential term; For a moment Error term; For a moment Error term; The time interval can be 0.1; It is a smoothing coefficient, which can be 0.8, used to reduce the noise effect of the differential term.
[0143] This invention achieves accurate calculation of the error term and its integral and derivative by comparing the response time with the target response time in real time and dynamically adjusting the integral and derivative weights in conjunction with the error rate. This effectively captures the trend of system performance changes, enhances the sensitivity of stress testing to system state and the accuracy of response, thereby improving the accuracy and stability of dynamic Poisson rate adjustment.
[0144] Optionally, in the above Figure 2 Based on one or more corresponding embodiments, in another optional embodiment provided by the present invention, step S210 may specifically include:
[0145] By using the real-time error rate and the preset error rate threshold in the running status data, the error rate constraint at the current moment can be obtained.
[0146] Specifically, in this embodiment of the invention, the real-time error rate in the running status data and the preset error rate threshold can be input into the formula:
[0147] ,
[0148] Obtain the error rate constraint term at the current moment, where, For error rate constraints; For real-time error rate; Set a preset error rate threshold. When the actual error rate... Approaching or exceeding the threshold At that time, the constraint term decreases, reducing the request sending rate.
[0149] By utilizing the CPU and memory usage data from the runtime status data, the resource constraints at the current moment can be obtained.
[0150] Optionally, the resource constraints obtained in this embodiment of the invention are based on CPU utilization. It can be:
[0151] ,
[0152] The higher the CPU utilization, the smaller the constraint, which dynamically reduces the stress generation rate and protects the stable operation of the system.
[0153] Optionally, the resource constraints obtained in this embodiment of the invention are based on memory utilization. It can be:
[0154] ,
[0155] in, The preset memory usage threshold can be set to 0.8. If the current usage exceeds the threshold, the resource constraint output will be 0 to prevent further pressure; if it is much lower than the threshold, the resource constraint will be close to 1, and the pressure can be appropriately increased.
[0156] This invention generates error rate constraints by comparing the error rate with a preset threshold in real time. At the same time, it combines CPU and memory usage to assess system resource load, dynamically reflecting the system's stress-bearing capacity, effectively preventing overload risks, ensuring that the request rate is adjusted within a safe range during stress testing, and improving system stability and test reliability.
[0157] Optionally, in the above Figure 1 Based on one or more corresponding embodiments, in another optional embodiment provided by the present invention, before step S130, the method may further include:
[0158] Determine whether the running status data meets the preset circuit breaker trigger condition. If not, proceed to step S130. If yes, follow the gradual recovery strategy to gradually restore the target dynamic Poisson rate from one proportion of the preset benchmark Poisson rate to another proportion over multiple consecutive time periods until the running status data no longer meets the preset circuit breaker trigger condition.
[0159] The preset circuit breaker trigger conditions refer to the threshold conditions used to determine whether it is necessary to temporarily interrupt or reduce the test intensity to protect the stability of the system under test. When the operating status data of the system under test reaches or exceeds these thresholds, the "circuit breaker" mechanism is triggered to stop or limit the sending of stress requests, thereby avoiding system overload or crash.
[0160] Optionally, the preset circuit breaker triggering conditions provided in the embodiments of the present invention include at least one of the following: the real-time error rate exceeds a first threshold; the CPU utilization rate exceeds a second threshold and the duration exceeds a first time; the real-time response time exceeds a preset multiple of the target response time.
[0161] As examples, embodiments of the present invention can determine that the system is in a serious abnormal or unavailable state when the real-time error rate is greater than or equal to 50%, or that the system CPU load is too high and maintains a high load for a long time when the CPU utilization is greater than or equal to 95% for more than 3 seconds, which may lead to slow response or service unavailability. Furthermore, it can determine that the interface response time is seriously beyond expectations and the system performance is extremely degraded when the real-time response time is greater than or equal to 5 times the target response time.
[0162] The gradual recovery strategy refers to the system not immediately returning to normal pressure level after the circuit breaker is triggered, but gradually increasing the target dynamic Poisson rate (i.e., request rate) according to multiple preset consecutive time periods to achieve robust recovery of stress test requests, prevent the system from overloading again due to a sudden increase in pressure, and ensure a smooth and safe pressure recovery process.
[0163] Optionally, the progressive recovery strategy provided in this embodiment of the invention may include: during a first recovery period, setting the target dynamic Poisson rate to a first proportion of a preset benchmark Poisson rate, and restricting the transmission of only specific types of requests. During a second recovery period, setting the target dynamic Poisson rate to a second proportion of the preset benchmark Poisson rate, and allowing the transmission of core service requests, wherein the second proportion is greater than the first proportion. During a third recovery period, setting the target dynamic Poisson rate to a third proportion of the preset benchmark Poisson rate, and allowing the transmission of non-core service requests, wherein the third proportion is greater than the second proportion.
[0164] As examples, embodiments of the present invention can set the target dynamic Poisson rate to 30% of the baseline Poisson rate during the 0-1 second phase, and only allow low-risk GET requests to be sent, ensuring the system can initially withstand pressure. During the 1-3 second phase, the target dynamic Poisson rate is increased to 60% of the baseline Poisson rate, and core business flows are opened for testing, gradually increasing the pressure. During the 3-5 second phase, the target dynamic Poisson rate is increased to 80% of the baseline Poisson rate, allowing non-core business flows to resume testing, approaching normal pressure levels. After 5 seconds, the dynamic calculation logic is fully restored, achieving normal dynamic pressure adjustment.
[0165] This invention, through a phased approach of gradually increasing the target dynamic Poisson's rate and progressively opening different types of requests, employs a gradual recovery strategy to smoothly and safely restore system load, avoiding sudden pressure that could cause system overload again, and ensuring the continuity of stress testing and the stable operation of the system under test.
[0166] This invention, by determining whether the running status data meets the preset circuit breaker triggering conditions before generating the test request interval sequence, and by gradually adjusting the target dynamic Poisson's rate using a progressive recovery strategy when triggered, can effectively prevent the system from being damaged due to overload, ensure the safety and continuity of the stress test process, and improve the reliability of the test and the stability of the system.
[0167] Optionally, embodiments of the present invention can use Grafana to achieve real-time visualization, displaying the target dynamic Poisson rate change curve, real-time response time, real-time error rate, CPU utilization and memory utilization trends, as well as circuit breaker recovery status, and generating a test report. The test report includes the system's critical Poisson rate value, bottleneck nodes (such as CPU overload or response time timeout), error rate distribution, and test pass rate, comprehensively reflecting the performance status of the system under test.
[0168] Although the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous.
[0169] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0170] Corresponding to the above method embodiments, this invention also provides an interface stress testing device, the structure of which is as follows: Figure 3 As shown, it may include: a running status data acquisition unit 10, a dynamic adjustment factor acquisition unit 20, a target dynamic Poisson rate determination unit 30, a test request interval sequence generation unit 40, an interface stress test request sending unit 50, and a response result receiving unit 60.
[0171] The operating status data acquisition unit 10 is used to acquire the operating status data of the system under test at the current moment.
[0172] The dynamic adjustment factor acquisition unit 20 is used to obtain the dynamic adjustment factor at the current moment based on the running status data and the preset performance target.
[0173] The target dynamic Poisson rate determination unit 30 is used to determine the target dynamic Poisson rate at the current moment using a dynamic adjustment factor and a preset benchmark Poisson rate.
[0174] The test request interval sequence generation unit 40 is used to generate a test request interval sequence according to the target dynamic Poisson rate.
[0175] The interface stress test request sending unit 50 is used to send interface stress test requests to the system under test according to the test request interval sequence.
[0176] The response result receiving unit 60 is used to receive the response result of the interface stress test request.
[0177] Optionally, the interface stress testing device may also include a data update unit.
[0178] The data update unit is used to trigger the dynamic adjustment factor acquisition unit 20 to perform the next round of dynamic adjustment of the Poisson rate after the response result receiving unit 60 receives the response result of the interface stress test request.
[0179] Optionally, the dynamic adjustment factor acquisition unit 20 may include: an adjustment item data acquisition subunit and a constraint item data acquisition subunit.
[0180] The adjustment term data acquisition sub-unit is used to obtain the integral-derivative adjustment term of the system under test at the current moment using the operating status data and the preset target response time.
[0181] The constraint data acquisition subunit is used to obtain the error rate constraint and resource constraint at the current moment using the running status data and the preset error rate threshold.
[0182] Optionally, the adjustment term data acquisition subunit can be used to obtain the error term at the current moment using the real-time response time and the preset target response time in the operating status data; to obtain the dynamic integral weight at the current moment using the error term at the current moment and the real-time error rate in the operating status data; to obtain the error integral term at the current moment using the error term at the current moment, the error term at the previous moment, and the error integral term at the previous moment; to obtain the dynamic differential weight at the current moment using the rate of change between the error term at the current moment and the error term at the previous moment; to obtain the error differential term at the current moment using the difference between the error term at the current moment and the error term at the previous moment; and to obtain the integral-derivative adjustment term of the tested system at the current moment using the error term at the current moment, the dynamic integral weight, the error integral term, the dynamic differential weight, and the error differential term.
[0183] Optionally, the constraint data acquisition subunit can be used to obtain the error rate constraint at the current moment by using the real-time error rate and preset error rate threshold in the running status data; and to obtain the resource constraint at the current moment by using the CPU utilization and memory utilization in the running status data.
[0184] Optionally, the adjustment term data acquisition sub-unit can be used to input the current error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term into the formula:
[0185] ;
[0186] Obtain the integral-derivative adjustment term, where, Indicates the current time; For integral-differential adjustment terms; This represents the error term at the current moment; This represents the dynamic integral weight at the current moment; This is the integral term of the error at the current moment; The dynamic differential weight at the current moment; This is the differential term of the error at the current moment.
[0187] Optionally, the target dynamic Poisson rate determination unit 30 can be used to input the preset benchmark Poisson rate, integral-derivative adjustment term, error rate constraint term, and resource constraint term into the formula:
[0188] ;
[0189] Obtain the target dynamic Poisson rate at the current moment, where, The target dynamic Poisson's law; The preset benchmark Poisson's ratio; For integral-differential adjustment terms; For error rate constraints; This is a resource constraint.
[0190] Optionally, the interface pressure testing device may also include a fuse trigger determination unit.
[0191] The circuit breaker trigger determination unit is used to determine whether the running status data meets the preset circuit breaker trigger conditions before the test request interval sequence generation unit 40 generates the test request interval sequence according to the target dynamic Poisson rate. If not, the test request interval sequence generation unit 40 is triggered. If so, the target dynamic Poisson rate is gradually restored from one proportion of the preset benchmark Poisson rate to another proportion in multiple consecutive time periods according to the gradual recovery strategy, until the running status data no longer meets the preset circuit breaker trigger conditions.
[0192] Optionally, the gradual recovery strategy includes: during a first recovery period, setting the target dynamic Poisson rate to a first proportion of a preset benchmark Poisson rate and restricting the sending of only specific types of requests; during a second recovery period, setting the target dynamic Poisson rate to a second proportion of the preset benchmark Poisson rate and allowing the sending of core business requests, wherein the second proportion is greater than the first proportion; and during a third recovery period, setting the target dynamic Poisson rate to a third proportion of the preset benchmark Poisson rate and allowing the sending of non-core business requests, wherein the third proportion is greater than the second proportion.
[0193] This invention provides an interface stress testing device, which is used to: obtain the operating status data of the system under test at the current moment; obtain the dynamic adjustment factor at the current moment based on the operating status data and a preset performance target; determine the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and a preset benchmark Poisson rate; generate a test request interval sequence according to the target dynamic Poisson rate; send interface stress test requests to the system under test according to the test request interval sequence; and receive the response results of the interface stress test requests. This invention dynamically calculates and adjusts the Poisson rate based on the real-time response results and resource status of the system under test, enabling the test pressure to adaptively increase or decrease with system performance, thereby automatically simulating the behavioral changes of real users when facing system lag, accurately detecting the system's critical state, and avoiding invalid or overloaded testing, ultimately comprehensively improving the authenticity, effectiveness, and security of the test.
[0194] Regarding the apparatus in the above embodiments, the specific manner in which each unit performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0195] The interface stress testing device includes a processor and a memory. The aforementioned operating status data acquisition unit 10, dynamic adjustment factor acquisition unit 20, target dynamic Poisson rate determination unit 30, test request interval sequence generation unit 40, interface stress test request sending unit 50, and response result receiving unit 60 are all stored as program units in the memory. The processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0196] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, real-time data on the operating status of the system under test is collected and dynamically calculated using preset performance targets. This calculation, combined with a benchmark Poisson's ratio, determines the target dynamic Poisson's ratio. Based on this, test request intervals are generated, stress test requests are sent to the system, and response results are received to update the status data, enabling the next round of adaptive adjustments.
[0197] This invention provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the interface stress testing method.
[0198] This invention provides a processor for running a program, wherein the program executes the interface stress testing method during runtime.
[0199] like Figure 4 As shown, this embodiment of the invention provides an electronic device 1000, which includes at least one processor 1001, at least one memory 1002 connected to the processor 1001, and a bus 1003. The processor 1001 and the memory 1002 communicate with each other via the bus 1003. The processor 1001 is used to call program instructions in the memory 1002 to execute the aforementioned interface stress testing method. The electronic device in this document can be a server, PC, PAD, mobile phone, etc.
[0200] The present invention also provides a computer program product that, when executed on an electronic device, is suitable for executing a program that initializes an interface stress test method step.
[0201] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, electronic devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0202] In a typical configuration, an electronic device includes one or more processors (CPUs), memory, and a bus. The electronic device may also include input / output interfaces, network interfaces, etc.
[0203] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM, and memory includes at least one memory chip. Memory is an example of computer-readable media.
[0204] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0205] In the description of this invention, it should be understood that if the terms "upper", "lower", "front", "rear", "left" and "right" are used to indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, they are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the position or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention.
[0206] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0207] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0208] The above are merely embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the present invention.
Claims
1. An interface stress testing method, characterized in that, include: Obtain the operating status data of the system under test at the current moment; Based on the operating status data and the preset performance target, the dynamic adjustment factor at the current moment is obtained; The target dynamic Poisson rate at the current moment is determined using the dynamic adjustment factor and the preset benchmark Poisson rate. Generate a test request interval sequence according to the target dynamic Poisson rate; Send interface stress test requests to the system under test according to the test request interval sequence; Receive the response result of the interface stress test request.
2. The method according to claim 1, characterized in that, After receiving the response result of the interface stress test request, the method further includes: Update the running status data based on the response result, return to the step of obtaining the dynamic adjustment factor at the current moment based on the running status data and the preset performance target, so as to perform the next round of dynamic adjustment of Poisson's rate.
3. The method according to claim 1, characterized in that, The step of obtaining the dynamic adjustment factor at the current moment based on the operating status data and the preset performance target includes: Using the operating status data and the preset target response time, the integral-derivative adjustment term of the system under test at the current moment is obtained; Using the running status data and the preset error rate threshold, the error rate constraint and resource constraint at the current moment are obtained.
4. The method according to claim 3, characterized in that, The step of obtaining the integral-derivative adjustment term of the system under test at the current moment using the operating status data and the preset target response time includes: The error term at the current moment is obtained by using the real-time response time and the preset target response time in the operation status data; The dynamic integral weight at the current moment is obtained by using the error term at the current moment and the real-time error rate in the running status data. The error integral term at the current moment is obtained by using the error term at the current moment, the error term at the previous moment, and the error integral term at the previous moment. The dynamic differential weight at the current moment is obtained by using the rate of change between the error term at the current moment and the error term at the previous moment. The error differential term at the current moment is obtained by using the difference between the error term at the current moment and the error term at the previous moment; Using the error term, dynamic integral weight, error integral term, dynamic differential weight, and error differential term at the current moment, the integral-differential adjustment term of the system under test at the current moment is obtained.
5. The method according to claim 3, characterized in that, The step of obtaining the error rate constraint and resource constraint at the current moment using the running status data and the preset error rate threshold includes: Using the real-time error rate and the preset error rate threshold in the running status data, the error rate constraint term at the current moment is obtained; By utilizing the CPU utilization and memory utilization in the running status data, the resource constraints at the current moment are obtained.
6. The method according to claim 4, characterized in that, The step of obtaining the integral-derivative adjustment term of the system under test at the current moment using the error term, dynamic integral weight, error integral term, dynamic derivative weight, and error derivative term includes: Input the error term, dynamic integral weight, error integral term, dynamic derivative weight, and error derivative term at the current moment into the formula: ; Obtain the integral-derivative adjustment term, where, Indicates the current moment; This is the integral-differential adjustment term; This refers to the error term at the current moment; The dynamic integral weight at the current moment; This is the integral term of the error at the current moment; The dynamic differential weight at the current moment; This is the differential term of the error at the current moment.
7. The method according to claim 3, characterized in that, The step of determining the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and the preset benchmark Poisson rate includes: Input the preset benchmark Poisson ratio, the integral-derivative adjustment term, the error rate constraint term, and the resource constraint term into the formula: ; Obtain the target dynamic Poisson rate at the current moment, where, The target dynamic Poisson's ratio; The preset reference Poisson rate; This is the integral-differential adjustment term; For the error rate constraint term; This refers to the resource constraint.
8. The method according to any one of claims 1 to 7, characterized in that, Before generating the test request interval sequence according to the target dynamic Poisson rate, the method further includes: Determine whether the running status data meets the preset circuit breaker trigger condition. If not, execute the step of generating a test request interval sequence according to the target dynamic Poisson rate. If yes, follow a progressive recovery strategy to gradually restore the target dynamic Poisson rate from one proportion of the preset benchmark Poisson rate to another proportion over multiple consecutive time periods until the running status data no longer meets the preset circuit breaker trigger condition.
9. The method according to claim 8, characterized in that, The gradual recovery strategy includes: During the first recovery period, the target dynamic Poisson rate is set to a first proportion of the preset benchmark Poisson rate, and only specific types of requests are restricted from being sent. During the second recovery period, the target dynamic Poisson rate is set to a second proportion of the preset benchmark Poisson rate, and core service requests are allowed to be sent, wherein the second proportion is greater than the first proportion; During the third recovery period, the target dynamic Poisson rate is set to a third proportion of the preset benchmark Poisson rate, and non-core business requests are allowed to be sent, wherein the third proportion is greater than the second proportion.
10. An interface stress testing device, characterized in that, include: The unit includes a running status data acquisition unit, a dynamic adjustment factor acquisition unit, a target dynamic Poisson rate determination unit, a test request interval sequence generation unit, an interface stress test request sending unit, and a response result receiving unit. The operating status data acquisition unit is used to acquire the operating status data of the system under test at the current moment; The dynamic adjustment factor acquisition unit is used to obtain the dynamic adjustment factor at the current moment based on the operating status data and the preset performance target. The target dynamic Poisson rate determination unit is used to determine the target dynamic Poisson rate at the current moment using the dynamic adjustment factor and the preset benchmark Poisson rate. The test request interval sequence generation unit is used to generate a test request interval sequence according to the target dynamic Poisson rate; The interface stress test request sending unit is used to send interface stress test requests to the system under test according to the test request interval sequence. The response result receiving unit is used to receive the response result of the interface stress test request.