Pressure testing method and system, storage medium and computer equipment
By obtaining the thread status of the pressure test agent, calculating and updating the number of threads according to the control parameters, the problem that the pressure test method in the prior art cannot accurately simulate the real peak flow, and the precise control and efficient reproduction of the pressure test agent flow are achieved.
Patent Information
- Application Number
- CN202510392896.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-07-08
AI Technical Summary
Existing stress testing methods cannot accurately simulate real peak flow, resulting in poor pressure testing.
By obtaining the thread status of the pressure measurement agent, calculate the number of threads required at the current moment according to the control parameters, and notifying the agent to start the thread according to the thread status to perform pressure measurement, and update the thread status in real time until the pressure measurement task is completed.
It realizes accurate control of the flow of the pressure measurement agent, accurately reproduces the flow at the real peak moment, and improves the efficiency and accuracy of the pressure measurement.
Smart Images

Figure CN120276952A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of pressure testing, and particularly to a pressure testing method, system, storage medium, and computer device. Background Art
[0002] Currently, during the performance pressure testing of software interfaces, usually a pressure testing proxy machine is used to send a specific amount of traffic to the server to simulate the impact of real peak traffic on the server, so as to identify the server bottleneck or potential problems.
[0003] In the prior art, the parameters related to traffic sending control include the maximum number of available threads, the initial number of threads, the thread increment amount, and the increment interval time. At the beginning of the pressure test, a certain number (the initial number of threads) of threads are started first, and then after a certain time (the increment interval time), a certain amount (the thread increment amount) of threads are added, and this increment process is continuously run until the number of threads used reaches the maximum available number (the maximum number of available threads), that is, after the threads are used up, the maximum number of threads is maintained without further increase until the end of this pressure test.
[0004] Since a thread will be in a state of waiting for a response after sending a request, and no more requests can be sent during this process. Assuming that the time for the server to respond to a request is greater than 1 second, and the increment interval time is also greater than 1 second, then after starting in the above manner, at the first second, all threads each send a request and then all are in a state of waiting for the business server to respond; at the beginning of the second second, all threads are still in a waiting state, so the number of requests sent by the pressure testing machine at the beginning of the second second is 0, which further leads to the inability to use this method to simulate the process of continuous traffic growth in reality.
[0005] Moreover, after a thread is started, it will be in an "infinite loop" of sending, waiting, receiving a response, and sending again... Assuming that the response time of the server is 2 milliseconds, ignoring the delay time of the message on the transmission line and the processing time of the response by the pressure testing machine, then according to the above process, a single thread will send and receive 500 times within 1 second, that is, the simulated traffic of a single thread within 1 second is fixed at 500, and in this way, it is also impossible to achieve the process of gradually increasing traffic during the real traffic peak.
[0006] Therefore, in actual operation, there are often large differences between the traffic simulated by the above method and the traffic actually expected to be simulated, resulting in the inability of the pressure testing process to replicate the actual peak traffic. Summary of the Invention
[0007] The purpose of this application aims to solve at least one of the above technical defects, especially the technical defect that there are large differences between the traffic simulated by the pressure testing method in the prior art and the traffic actually expected to be simulated, resulting in poor pressure testing effects.
[0008] This application provides a stress testing method, which is applied to a stress testing server and includes:
[0009] When performing a stress testing task, obtain the control parameters input by the user, as well as the thread states of all available threads of all stress testing agents connected to this server;
[0010] Calculate the first number of threads required for stress testing at the current moment according to the control parameters, and notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work according to the first number of threads and the thread states of each available thread;
[0011] Obtain the execution results returned after the at least one stress testing agent finishes execution, update the thread states of the threads performing this stress testing work according to the execution results, and after replacing the current moment with the next moment, continue to return and execute the step of calculating the first number of threads required for stress testing at the current moment according to the control parameters and its subsequent steps until the stress testing task is completed.
[0012] Optionally, the control parameters include the initial number of threads, the thread increment value, and the increment interval corresponding to the stress testing task;
[0013] The step of calculating the first number of threads required for stress testing at the current moment according to the control parameters includes:
[0014] Calculate the first number of threads required for stress testing at the current moment according to the initial number of threads, the thread increment value, and the increment interval.
[0015] Optionally, the step of notifying at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work according to the first number of threads and the thread states of each available thread includes:
[0016] Determine the second number of threads corresponding to the threads in the idle state according to the thread states of each available thread;
[0017] Determine whether the second number of threads is greater than or equal to the first number of threads;
[0018] If so, notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work;
[0019] Otherwise, end this stress testing task and report and record this error.
[0020] Optionally, the step of notifying at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work includes:
[0021] Determine the third number of threads corresponding to the threads in the idle state in each stress testing agent machine;
[0022] Determine the target stress testing agent machine for performing this stress testing work and the target number of threads to be started by the target stress testing agent machine according to the first number of threads and the third number of threads;
[0023] Send the pre-configured stress testing script and stress testing commands to the target stress testing agent machine, so that the target stress testing agent machine starts threads corresponding to the target number of threads according to the stress testing commands to execute the stress testing script once.
[0024] Optionally, the method further includes:
[0025] Determine the third number of threads corresponding to the threads in the idle state in each stress testing agent machine;
[0026] Adjust the number of stress testing agent machines connected to this server according to the first number of threads, the third number of threads, and the response time of the software interface.
[0027] Optionally, the method further includes:
[0028] During the stress testing process or when ending the stress testing task, after summarizing the execution results returned each time when performing the stress testing work by time period, determine the number of sent requests, the number of received responses, and the number of errors within this period of time;
[0029] Generate a stress testing report corresponding to the number of sent requests, the number of received responses, and the number of errors within this period of time, and draw a report curve graph, where the report curve graph at least includes a sent request number curve and a received response number curve.
[0030] Optionally, the method further includes:
[0031] Obtain the actual peak traffic curve;
[0032] Compare the sent request number curve with the actual peak traffic curve, and determine whether the stress testing traffic when performing this stress testing task truly simulates the actual traffic according to the comparison result;
[0033] If the actual traffic is not truly simulated, then after adjusting the control parameters according to the comparison result, re-execute the step of calculating the first number of threads required for stress testing at the current moment and its subsequent steps according to the control parameters until the stress testing task is completed.
[0034] This application also provides a stress testing system, the system includes a stress server, at least one stress testing agent machine connected to the stress server, multiple threads are configured in the at least one stress testing agent machine, and the stress server executes the stress testing method according to any one of the above embodiments.
[0035] The present application also provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the steps of the stress testing method as described in any one of the above embodiments.
[0036] The present application also provides a computer device, including: one or more processors, and a memory;
[0037] The memory stores computer-readable instructions. When the computer-readable instructions are executed by the one or more processors, the steps of the stress testing method as described in any one of the above embodiments are executed.
[0038] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:
[0039] For the stress testing method, system, storage medium and computer device provided by the present application, when the stress testing server executes a stress testing task, it can first obtain the control parameters input by the user and the thread states of all available threads of all stress testing agents connected to this server, and then calculate the first number of threads required for stress testing at the current moment according to the control parameters, and according to the first number of threads and the thread states of each available thread, notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute the current stress testing work. After that, obtain the execution results returned after at least one stress testing agent finishes execution, and update the thread states of the threads executing the current stress testing work according to the execution results. And after replacing the current moment with the next moment, continue to execute calculating the first number of threads required for stress testing at the current moment according to the control parameters, and according to the first number of threads and the thread states of each available thread, notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute the current stress testing work until the stress testing task is completed. The present application realizes the precise control of the simulated traffic of the stress testing agent by precisely controlling the number of effective threads used by the stress testing agent per second and the number of requests sent by each thread per second, so as to achieve the precise reproduction of the traffic at the real peak moment by the stress testing agent. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0041] Figure 1A flowchart of a pressure testing method provided by an embodiment of the present application;
[0042] Figure 2 A process diagram of notifying a stress testing agent to start a thread to execute stress testing work provided by an embodiment of the present application;
[0043] Figure 3 A structural diagram of a pressure testing system provided by an embodiment of the present application;
[0044] Figure 4 An internal structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0045] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0046] In one embodiment, as Figure 1 shown, Figure 1 A flowchart of a pressure testing method provided by an embodiment of the present application; The present application provides a pressure testing method, which is applied to a stress testing server and may include:
[0047] S110: When executing a stress testing task, obtain control parameters input by a user, and the thread states of all available threads of all stress testing agents connected to this server.
[0048] In this step, when executing a stress testing task, control parameters related to the current stress testing task input by the user through a human-computer interaction management page can be obtained. The control parameters include but are not limited to the initial number of threads, the thread increment value, and the increment interval, etc., and can be specifically set according to the actual situation, and are not limited here. Then, the stress testing server of the present application can also obtain the thread states of all available threads of all stress testing agents connected to this server, so that the stress testing process of the stress testing agents can be precisely controlled according to the control parameters and the thread states.
[0049] Among them, the stress testing server of the present application is the management and control center of the stress testing system. The stress testing server includes a human-computer input side, an agent side, and a result output side. On the human-computer input side, it is responsible for providing a human-computer interaction management page and receiving various parameters required for stress testing configured by the user; on the agent side, it is responsible for controlling the stress testing agent, coordinating and calculating available thread resources, sending stress testing instructions to the stress testing agent, and receiving log warnings and the like returned by the stress testing agent; on the result output side, the stress testing server is also responsible for processing data such as log warnings to form a report and outputting it to the monitoring page.
[0050] The stress testing agent of the present application is a machine that executes stress testing tasks. It is responsible for executing the stress testing script sent by the stress testing server and performing stress testing according to the stress testing mechanism provided by the stress testing server. After completing the stress testing, it reports the generated data to the stress testing server. The number of stress testing agents can be dynamically allocated. One stress testing server can manage several stress testing agents at the same time. The number of threads that a stress testing agent can start depends on the hardware configuration of the agent. Generally, a reasonable number of threads will be determined before stress testing.
[0051] Furthermore, the thread states of the stress testing agent in the present application include states such as idle, running, and blocked. After a thread is started, it is in the idle state. When a thread receives a task to execute, it will be in the running state. After the task is completed, it changes from the running state to the idle state. If an exception occurs during the task execution, it will enter the blocked state, and the blocked state will be processed by the monitor and the log will be recorded.
[0052] S120: Calculate the first number of threads required for stress testing at the current moment according to the control parameter, and notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute the current stress testing work according to the first number of threads and the thread states of each available thread.
[0053] In this step, after obtaining the control parameter input by the user and the thread states of all available threads of all stress testing agents connected to this server through S110, the present application can calculate the first number of threads required for stress testing at the current moment according to the control parameter. In this way, according to the first number of threads and the thread states of each available thread, at least one stress testing agent for the task to be executed can be determined, and then at least one stress testing agent is notified to start the threads corresponding to the first number of threads to execute the current stress testing work.
[0054] It can be understood that when the thread in the present application executes the stress test work, it forms a complete request through three actions: sending, waiting, and receiving a response. After each thread in the present application is started, it begins to send a request, and then waits for the response from the business server. Until a response is received, it indicates that the current stress test work is completed. Each time a server response is received by a thread, the stress test traffic for the second when the response is received is incremented by 1. The total number of responses received by all available threads in that second is the simulated traffic value for that second. Among them, each thread in the present application only executes once each time a stress test is performed, that is, by sending a single request, to solve the problem in the prior art that once a thread is started, the number of executions is uncontrollable.
[0055] S130: Obtain the execution results returned after at least one stress test agent finishes execution, and update the thread status of the thread that is currently performing the stress test work according to the execution results. After replacing the current moment with the next moment, continue to return and execute the calculation of the first number of threads required for the stress test at the current moment according to the control parameters and its subsequent steps until the stress test task is completed.
[0056] In this step, after notifying at least one stress test agent to start the threads corresponding to the first number of threads to execute the current stress test work according to the first number of threads and the thread status of each available thread through S120, the present application can also obtain the execution results returned after at least one stress test agent finishes execution, update the thread status corresponding to the thread that is currently performing the stress test work according to the execution results, then replace the current moment with the next moment, and then continue to calculate the first number of threads required for the stress test at the current moment according to the control parameters, and determine at least one stress test agent for the task to be executed according to the first number of threads and the thread status of each available thread, and then notify at least one stress test agent to start the threads corresponding to the first number of threads to execute the current stress test work until the stress test task is completed.
[0057] Specifically, after the stress test agent in the present application executes the stress test work, it can return the execution results to the stress test server. The execution results include, but are not limited to, the number of requests sent, the number of responses received, and the number of errors of all threads that are currently performing the stress test work. The number of errors includes, but is not limited to, the number of threads that do not receive a server response until timeout, the number of threads with failed sends, and the number of threads that cannot accept responses, etc., which are not limited here.
[0058] When the stress test server in the present application receives the execution results returned by the stress test agent, it can update the thread status of the thread that is currently performing the stress test work according to the execution results. In this way, during the subsequent stress test process, the size of the simulated traffic can be accurately controlled by controlling the number of effectively available threads in a certain time slice and the number of requests sent by each thread, thereby solving the problem in the prior art that although there are threads, there are threads that do not actually work due to the inability to release threads in a timely manner.
[0059] Furthermore, the time interval between the current moment and the next moment of the present application can be determined according to the control parameters input by the user, so that the stress testing server can automatically execute the stress testing process according to the control parameters, thereby effectively improving the stress testing efficiency.
[0060] In the above embodiment, when the stress testing server executes the stress testing task, it can first obtain the control parameters input by the user and the thread states of all available threads of all stress testing agents connected to this server, and then calculate the first number of threads required for stress testing at the current moment according to the control parameters. And according to the first number of threads and the thread states of each available thread, after notifying at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work, obtain the execution results returned after at least one stress testing agent finishes execution, and update the thread states of the threads executing this stress testing work according to the execution results. And after replacing the current moment with the next moment, continue to execute calculating the first number of threads required for stress testing at the current moment according to the control parameters, and according to the first number of threads and the thread states of each available thread, notify at least one stress testing agent to start the threads corresponding to the first number of threads to execute this stress testing work until the stress testing task is completed. The present application realizes the precise control of the simulated traffic of the stress testing agent by precisely controlling the number of effective threads used by the stress testing agent per second and the number of requests sent by each thread per second, so as to accurately reproduce the traffic at the real peak moment with the stress testing agent.
[0061] In one embodiment, the control parameters may include the initial number of threads, the thread increment value, and the increment interval corresponding to the stress testing task.
[0062] Calculating the first number of threads required for stress testing at the current moment according to the control parameters in S120 may include:
[0063] Calculating the first number of threads required for stress testing at the current moment according to the initial number of threads, the thread increment value, and the increment interval.
[0064] In this embodiment, the control parameters required for this stress testing task input by the user may include the initial number of threads, the thread increment value, and the increment interval. Among them, the initial number of threads refers to the number of threads started when the stress testing work is first executed, the thread increment value refers to the difference between the number of threads started when the stress testing work is executed next time and the number of threads started when the stress testing work was executed last time, and the increment interval refers to the time interval between the moment when the stress testing work is executed next time and the moment when the stress testing work was executed last time.
[0065] After the present application determines the initial number of threads, the thread increment value, and the increment interval of this stress testing task, it can calculate the first number of threads required for stress testing at the current moment according to the initial number of threads, the thread increment value, and the increment interval.
[0066] For example, when the initial number of threads of the present application is 10, the thread increment value is 1, and the increment interval is 1 second, the number of threads used at the 1st second is 10, the number of threads used at the 2nd second is 10 + 1 * 1 = 11... the number of threads used at the nth second is 10 + 1 * n = (10 + n). Thus, the first number of threads corresponding to each moment can be calculated.
[0067] Furthermore, since the numerical settings of the initial number of threads, the thread increment value, and the increment interval have a certain impact on the subsequent stress testing work. For example, assume that each stress testing machine has 100 available threads, and a total of 2 stress testing machines can be started, then there are a total of 200 available threads. According to the above parameter settings, 10 threads are used at the 1st second, then there are 190 idle threads (10 threads are used on one stress testing machine, and the other stress testing machine is completely idle). At the 190th second, exactly 200 threads are used up. In this way, at the 191st second, there may be a situation where there are not enough threads. Therefore, when setting the control parameters, enough idle threads can be reserved according to the actual situation to successfully complete the stress testing task.
[0068] In one embodiment, in S120, according to the first number of threads and the thread states of each available thread, notifying at least one stress testing agent to start threads corresponding to the first number of threads to perform the current stress testing work may include:
[0069] S121: Determine the second number of threads corresponding to the threads in the idle state according to the thread states of each available thread.
[0070] S122: Determine whether the second number of threads is greater than or equal to the first number of threads; if so, execute S123; otherwise, execute S124.
[0071] S123: Notify at least one stress testing agent to start threads corresponding to the first number of threads to perform the current stress testing work.
[0072] S124: End the current stress testing task and report and record the current error.
[0073] In this embodiment, when performing the stress testing work, the stress testing server may first determine at least one stress testing agent for the task to be executed according to the first number of threads and the thread states of each available thread, and then notify at least one stress testing agent to start threads corresponding to the first number of threads to perform the current stress testing work.
[0074] Specifically, the stress testing server in the present application can determine the number of second threads corresponding to the threads in the idle state according to the thread states of each available thread, and then compare the number of second threads with the number of first threads. If the number of second threads is greater than or equal to the number of first threads, it means that the threads in the idle state are sufficient to execute the current stress testing work. At this time, after determining at least one stress testing agent for the task to be executed, at least one stress testing agent can be notified to start the threads corresponding to the number of first threads to execute the current stress testing work. If the number of second threads is less than the number of first threads, it means that the threads in the idle state cannot meet the requirements of the current stress testing work. At this time, the current stress testing task can be ended, and after reporting this situation, the error of insufficient threads this time can be recorded for subsequent adjustment.
[0075] In one embodiment, as Figure 2 shown, Figure 2 is a schematic diagram of the process of notifying a stress testing agent to start a thread to execute stress testing work provided by an embodiment of the present application; notifying at least one stress testing agent to start the thread corresponding to the number of first threads to execute the current stress testing work in S120 may include:
[0076] S125: Determine the number of third threads corresponding to the threads in the idle state in each stress testing agent.
[0077] S126: Determine the target stress testing agent for executing the current stress testing work and the number of target threads to be started by the target stress testing agent according to the number of first threads and the number of third threads.
[0078] S127: Send the pre-configured stress testing script and stress testing command to the target stress testing agent, so that the target stress testing agent starts the thread corresponding to the number of target threads to execute a stress testing script according to the stress testing command.
[0079] In this embodiment, when the stress testing server notifies at least one stress testing agent to start the thread corresponding to the number of first threads to execute the current stress testing work, it can first determine the number of third threads corresponding to the threads in the idle state in each stress testing agent according to the thread states of each available thread, and then, in the order of each stress testing agent, determine the target stress testing agent for executing the current stress testing work and the number of target threads to be started in the target stress testing agent according to the number of first threads and the number of third threads. Then, send the pre-configured stress testing script and the stress testing command when executing the current stress testing work to the target stress testing agent, so that the target stress testing agent starts the thread corresponding to the number of target threads to execute a stress testing script according to the stress testing command.
[0080] For example, when the initial number of threads of the present application is 10, the thread increment value is 1, the increment interval is 1 second, and a total of 2 load testing machines can be started, with 100 threads available for each load testing machine, then a total of 200 threads are available. At the 1st second, 10 threads of the first load testing agent can be started, at the 2nd second, 11 threads of the first load testing agent can be started, and at the 190th second, all 200 threads are exactly used up. Through this process, the load testing task can be automatically executed, thereby effectively improving the load testing efficiency.
[0081] In one embodiment, the method may further include:
[0082] S128: Determine the third number of threads corresponding to the threads in the idle state in each load testing agent.
[0083] S129: Adjust the number of load testing agents connected to the present server according to the first number of threads, the third number of threads, and the response time of the software interface.
[0084] In this embodiment, when the second number of threads corresponding to the threads in the idle state is less than the first number of threads, it means that the threads in the idle state cannot meet the requirements of the current load testing work. At this time, the current load testing task can be ended, and after reporting this situation and recording the error that the threads are insufficient this time, the load testing server can also determine the third number of threads corresponding to the threads in the idle state in each load testing agent and the response time of the software interface according to the recorded content. In this way, the number of load testing agents connected to the present server can be adjusted according to the first number of threads, the third number of threads, and the response time of the software interface, such as adding one or more load testing agents, so as to smoothly complete the load testing task and improve the load testing efficiency at the same time.
[0085] In one embodiment, the method may further include:
[0086] S140: During the load testing process or when ending the load testing task, after summarizing the execution results returned each time when performing the load testing work by time period, determine the number of sent requests, the number of received responses, and the number of errors during this period.
[0087] S150: Generate a load testing report corresponding to the number of sent requests, the number of received responses, and the number of errors during this period, and draw a report curve graph, where the report curve graph at least includes a sent request number curve and a received response number curve.
[0088] In this embodiment, the load testing server can also summarize and output the load testing data in the form of graphs and charts during the load testing process and after the load testing ends as a load testing report, and this load testing report is used to analyze the current load testing situation.
[0089] In a specific implementation method, the stress testing server in the present application can summarize the execution results returned each time the stress testing work is executed by time period during the stress testing process or when the stress testing task is completed, and determine the number of requests sent, the number of responses received, and the number of errors within the period. In this way, a stress testing report corresponding to the number of requests sent, the number of responses received, and the number of errors within the period can be generated, and a report curve chart can be drawn. When generating a stress testing report and drawing a report curve chart, the present application can generate a stress testing report through the report provided by the stress testing tool and a third-party visualization tool, and draw a report curve chart, thereby meeting analysis requirements of different granularities.
[0090] Furthermore, the report curve graph of the present application includes at least a curve of the number of sent requests and a curve of the number of received responses. The curve of the number of received responses is the curve of the server processing capacity, so that the tester can clearly see the real-time status of the stress testing agent and the business server.
[0091] In one embodiment, the method may further include:
[0092] S160: Obtaining an actual peak flow curve.
[0093] S170: Compare the request number curve with the actual peak flow curve, and determine whether the stress testing flow during the stress testing task is truly simulating the actual flow according to the comparison result.
[0094] S180: If the actual traffic is not truly simulated, after adjusting the control parameter according to the comparison result, re-execute the calculation of the first number of threads required for the stress test at the current moment according to the control parameter and subsequent steps until the stress test task is completed.
[0095] In this embodiment, during the stress testing process, when the present application summarizes the execution results returned each time the stress testing work is executed according to the time period, and determines the number of requests sent, the number of responses received, and the number of errors within the time period, and generates a stress testing report corresponding to the number of requests sent, the number of responses received, and the number of errors within the time period, and draws a report curve chart, the present application can also obtain the actual peak traffic curve, and then compare the sending request number curve in the report curve chart with the actual peak traffic curve, and judge whether the stress testing traffic when executing the stress testing task this time truly simulates the actual traffic based on the comparison result. If the actual traffic is not truly simulated, the control parameters are adjusted according to the comparison results, and the first number of threads required for the stress testing at the current moment is calculated according to the control parameters again, and at least one stress testing agent to be executed is determined based on the first number of threads and the thread status of each available thread, and at least one stress testing agent is notified to start the thread corresponding to the first number of threads to perform this stress testing work until the stress testing task is completed.
[0096] In the above embodiments, by comparing the curve of the number of sent requests with the curve of the actual peak traffic, it can be accurately determined whether the traffic during the current stress test task truly simulates the actual traffic. In the case where the actual traffic is not truly simulated, the control parameters are adjusted and the stress test task is executed again, so that the stress test simulated traffic more accurately matches the actual peak traffic curve, and a more realistic simulated peak traffic model is generated.
[0097] In one embodiment, as Figure 3 shown, Figure 3 is a schematic structural diagram of a stress test system provided by an embodiment of the present application; the present application also provides a stress test system, the system includes a stress server, at least one stress test agent machine connected to the stress server, a plurality of threads are configured in the at least one stress test agent machine, and the stress server executes the stress test method described in any one of the above embodiments.
[0098] In the above embodiments, when the stress test server executes the stress test task, it can first obtain the control parameters input by the user and the thread states of all available threads of all stress test agent machines connected to this server, and then calculate the first number of threads required for the stress test at the current moment according to the control parameters. And according to the first number of threads and the thread states of each available thread, notify at least one stress test agent machine to start the threads corresponding to the first number of threads to execute the current stress test work. After that, obtain the execution results returned after at least one stress test agent machine finishes execution, and update the thread states of the threads executing the current stress test work according to the execution results. And after replacing the current moment with the next moment, continue to execute calculating the first number of threads required for the stress test at the current moment according to the control parameters, and according to the first number of threads and the thread states of each available thread, notify at least one stress test agent machine to start the threads corresponding to the first number of threads to execute the current stress test work until the stress test task is completed. The present application realizes the precise control of the simulated traffic of the stress test agent machine by precisely controlling the number of effective threads used by the stress test agent machine per second and the number of requests sent by each thread per second, so as to accurately reproduce the traffic at the real peak moment with the stress test agent machine.
[0099] In one embodiment, the present application also provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, one or more processors are caused to execute the steps of the stress test method described in any one of the above embodiments.
[0100] In one embodiment, the present application also provides a computer device, including: one or more processors, and a memory.
[0101] The computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the one or more processors, the steps of the stress test method described in any of the above embodiments are executed.
[0102] Schematically, as Figure 4 shown, Figure 4 FIG. is a schematic internal structure diagram of a computer device provided by an embodiment of the present application. The computer device 300 may be provided as a server. Referring to Figure 4 , the computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by a memory 301 for storing instructions executable by the processing component 302, such as application programs. The application programs stored in the memory 301 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the stress test method of any of the above embodiments.
[0103] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as WindowsServer TM, Mac OS XTM, Unix TM, Linux TM, Free BSDTM or the like.
[0104] Those skilled in the art can understand that Figure 4 the structure shown in
[0105] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement. Finally, it should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the presence of additional identical elements in the process, method, article or device including the element.
[0106] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0107] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A pressure testing method, characterized in that The method is applied to a stress testing server and includes: When performing a stress testing task, obtaining control parameters input by a user, and the thread states of all available threads of all stress testing agents connected to this server; Calculating a first number of threads required for stress testing at the current moment according to the control parameters, and according to the first number of threads and the thread states of each available thread, notifying at least one stress testing agent to start threads corresponding to the first number of threads to execute this stress testing work; Obtaining the execution results returned after the at least one stress testing agent finishes execution, and according to the execution results, updating the thread states of the threads executing this stress testing work, and after replacing the current moment with the next moment, continuing to return and execute calculating the first number of threads required for stress testing at the current moment according to the control parameters and subsequent steps until the stress testing task is completed.
2. The pressure test method according to claim 1, characterized in that, The control parameters include an initial number of threads, a thread increment value, and an increment interval corresponding to the stress testing task; The calculating the first number of threads required for stress testing at the current moment according to the control parameters includes: Calculating the first number of threads required for stress testing at the current moment according to the initial number of threads, the thread increment value, and the increment interval.
3. The pressure test method according to claim 1, characterized in that, The notifying at least one stress testing agent to start threads corresponding to the first number of threads to execute this stress testing work according to the first number of threads and the thread states of each available thread includes: Determining a second number of threads corresponding to the threads in the idle state according to the thread states of each available thread; Determining whether the second number of threads is greater than or equal to the first number of threads; If so, notifying at least one stress testing agent to start threads corresponding to the first number of threads to execute this stress testing work; Otherwise, ending this stress testing task and reporting and recording this error.
4. The pressure test method according to claim 1, wherein The notifying at least one stress testing agent to start threads corresponding to the first number of threads to execute this stress testing work includes: Determining a third number of threads corresponding to the threads in the idle state in each stress testing agent; Determining a target stress testing agent for executing this stress testing work and the number of target threads to be started by the target stress testing agent according to the first number of threads and the third number of threads; Sending a pre-configured stress testing script and stress testing commands to the target stress testing agent, so that the target stress testing agent starts threads corresponding to the number of target threads according to the stress testing commands to execute the stress testing script once.
5. The pressure testing method according to claim 3, wherein, The method further includes: Determining a third number of threads corresponding to the threads in the idle state in each stress testing agent; Adjusting the number of stress testing agents connected to this server according to the first number of threads, the third number of threads, and the response time of the software interface.
6. The pressure testing method according to any one of claims 1-5, characterized in that, The method further includes: During the stress testing process or when ending the stress testing task, after summarizing the execution results returned each time when executing the stress testing work by time period, determining the number of sent requests, received responses, and error numbers during this period of time; Generating a stress testing report corresponding to the number of sent requests, received responses, and error numbers during this period of time, and drawing a report curve graph, where the report curve graph at least includes a sent request number curve and a received response number curve.
7. The pressure test method according to claim 6, wherein The method further includes: Obtain the actual peak traffic curve; Compare the sending request number curve with the actual peak traffic curve, and determine whether the stress test traffic during this stress test task truly simulates the actual traffic according to the comparison result; If the actual traffic is not truly simulated, after adjusting the control parameter according to the comparison result, re-execute the step of calculating the first number of threads required for stress testing at the current moment and its subsequent steps according to the control parameter until the stress test task is completed.
8. A pressure testing system, characterized in that, The system includes a pressure server, at least one stress test agent connected to the pressure server, multiple threads are configured in the at least one stress test agent, and the pressure server executes the stress test method according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored in the computer-readable storage medium, and when the computer-readable instructions are executed by one or more processors, one or more processors are caused to execute the steps of the stress test method according to any one of claims 1 to 7.
10. A computer device, characterized in that, Comprising: One or more processors, and a memory; Computer-readable instructions are stored in the memory, and when the computer-readable instructions are executed by the one or more processors, the steps of the stress test method according to any one of claims 1 to 7 are executed.
Citation Information
Patent Citations
A QPS-based dynamic adjustment method and related equipment
CN109284229A
Gradient-pressure teste method, device and electronic device
CN109308397A
Self-adaptive distributed system pressure measurement method, device and system
CN114448839A
Test task deployment method, system and equipment and computer storage medium
CN118427106A
Performance test method and device, equipment, storage medium and program product
CN118820098A