A load balancing test method and apparatus
By using automated testing methods, initial test scenarios are created based on the target system parameters of load balancing, and resource utilization is adjusted. This solves the problem of load balancing testing relying on manpower and experience, and achieves a more efficient testing process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-25
- Publication Date
- 2026-03-13
AI Technical Summary
Load balancing testing relies heavily on human resources and the experience of testers, resulting in low testing efficiency and a lack of standardization.
By creating an initial test scenario based on the target system parameters of load balancing, and adjusting the scenario parameters according to resource utilization, a target test scenario is formed, thus achieving automated testing.
It reduces reliance on human resources, improves testing speed and efficiency, and reduces the uncertainty of test results.
Smart Images

Figure CN115129418B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a load balancing testing method and apparatus. Background Technology
[0002] Currently, load balancing testing requires significant human resources, with many processes demanding human intervention. Furthermore, it necessitates highly experienced testers, whose experience directly impacts the testing process and results. For instance, an experienced tester might achieve better results in less time for the same load balancing test, while a less experienced tester might take longer with unsatisfactory results. Moreover, the reliance on individual tester experience leads to inconsistent and unstandardized testing procedures. All these factors contribute to the low efficiency of current load balancing testing.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a load balancing testing method and apparatus to at least solve the technical problem of low testing efficiency in the load balancing testing process.
[0005] According to one aspect of the embodiments of this application, a load balancing testing method is provided, applied to a load balancing testing application, the method comprising:
[0006] An initial test scenario is created based on the target system parameters of the load balancer, wherein the initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers;
[0007] The scenario parameters of the initial test scenario are adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and the set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold.
[0008] The load balancer was tested in the target test scenario, and the test results were obtained.
[0009] Optionally, creating an initial test scenario based on the target system parameters of the load balancer includes:
[0010] A first number of virtual machines are created based on the target system parameters for load balancing, thereby obtaining the initial client set and the initial server set.
[0011] The initial client set is connected to the load balancer, and the initial server set is attached to the backend of the load balancer, resulting in the initial client set, the load balancer, and the initial server set connected in sequence.
[0012] Connectivity verification is performed on the initial client set, the load balancer, and the initial server set that are connected sequentially.
[0013] If the connectivity verification of the sequentially connected initial client set, the load balancer, and the initial server set passes, the sequentially connected initial client set, the load balancer, and the initial server set will be determined as the initial test scenario.
[0014] Optionally, a first number of virtual machines are created on the cloud server according to the target system parameters of the load balancer, resulting in the initial client set and the initial server set, which include:
[0015] The target number of clients and the target number of servers corresponding to the target system parameters are obtained from the system parameters, the number of clients and the number of servers that have a corresponding relationship, wherein the first number is the sum of the number of target clients and the number of target servers;
[0016] Create virtual machines with the target number of clients, and install testing tools on the virtual machines with the target number of clients to obtain the initial client set;
[0017] Create the target number of virtual machines, and install a web service program on the target number of virtual machines to obtain the initial server set.
[0018] Optionally, adjusting the scenario parameters of the initial test scenario based on the first resource utilization rate of the load balancer includes:
[0019] During the process of increasing the load balancer in the initial test scenario, the first resource utilization rate of the load balancer in the initial test scenario is detected.
[0020] If the first resource utilization rate is detected to be lower than the resource utilization rate threshold, the scenario parameters of the initial test scenario are adjusted until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold.
[0021] The test scenario under the second resource utilization rate is determined as the target test scenario.
[0022] Optionally, during the process of increasing the load balancer in the initial test scenario, detecting the first resource utilization of the load balancer in the initial test scenario includes:
[0023] An initial virtual machine is created, and the initial client set is added to the client group of the initial virtual machine to obtain the target virtual machine as the control terminal of the initial test scenario;
[0024] In the initial test scenario, the load balancer is subjected to increased pressure.
[0025] When pressure is applied immediately, the utilization rate of the first resource of the load balancer is monitored through the target virtual machine.
[0026] Optionally, adjusting the scenario parameters of the initial test scenario until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold includes:
[0027] The performance parameters of the initial client set are adjusted from the first parameter to the second parameter to obtain the intermediate client set;
[0028] If the resource utilization of the test scenario including the intermediate client set is lower than the resource utilization threshold but the number of timeout messages of the intermediate client set exceeds the target number, the number of clients in the intermediate client set is adjusted from the second number to the third number, and / or the number of servers in the initial server set is adjusted from the fourth number to the fifth number to obtain the intermediate test scenario.
[0029] The intermediate test scenario includes a set of clients with a target performance parameter, wherein the target performance parameter is the maximum performance parameter reached by the initial client set when no timeout message occurs during the process of adjusting the performance parameter of the initial client set from the first parameter to the second parameter;
[0030] If the resource utilization of the intermediate test scenario, which includes a set of clients with the target performance parameter, is found to be lower than the resource utilization threshold, the performance parameter of the intermediate test scenario with the maximum performance parameter is adjusted.
[0031] Optionally, testing the load balancer in the target test scenario includes:
[0032] The load balancer is subjected to stress testing in the target test scenario.
[0033] During the stress test, the test metrics of the target test scenario are statistically analyzed and recorded to obtain the test results.
[0034] Optionally, during the stress test of the load balancer in the target test scenario, the method further includes:
[0035] Monitor the process identifier of the load balancer;
[0036] If an abnormal interruption is detected in the load balancing process, the stress test shall be stopped.
[0037] According to another aspect of the embodiments of this application, a load balancing testing apparatus is also provided, applied to load balancing testing applications, the apparatus comprising:
[0038] A creation module is used to create an initial test scenario based on the target system parameters of the load balancer. The initial test scenario includes an initial set of clients connected sequentially, the load balancer, and an initial set of servers.
[0039] An adjustment module is used to adjust the scenario parameters of the initial test scenario according to the first resource utilization rate of the load balancer to obtain a target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and a set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to a resource utilization rate threshold.
[0040] The testing module is used to test the load balancer in the target test scenario and obtain test results.
[0041] According to another aspect of the embodiments of this application, a storage medium is also provided, the storage medium including a stored program that executes the above-described method when the program is run.
[0042] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor performs the above-described method through the computer program.
[0043] In this embodiment, an initial test scenario is created based on the target system parameters of the load balancer. The initial test scenario includes an initial set of clients, a load balancer, and an initial set of servers connected sequentially. The scenario parameters of the initial test scenario are adjusted based on a first resource utilization rate of the load balancer to obtain a target test scenario. The first resource utilization rate indicates the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a target set of clients, a load balancer, and a target set of servers connected sequentially. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to a resource utilization threshold. The load balancer is then tested in the target test scenario to obtain the test results. The load balancing test application creates an initial test scenario based on the target system parameters of the load balancer. It then adjusts the scenario parameters of the initial test scenario based on the first resource utilization rate of the load balancer to obtain the target test scenario. This ensures that the second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization threshold. Using the target test scenario for automated load balancing testing saves manpower, eliminates reliance on tester experience, and reduces factors affecting test results. This achieves the goal of increasing test speed through automation, thereby improving the technical efficiency of the load balancing testing process and solving the technical problem of low testing efficiency. Attached Figure Description
[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a schematic diagram of the hardware environment for a load balancing test method according to an embodiment of this application;
[0047] Figure 2 This is a flowchart of an optional load balancing test method according to an embodiment of this application;
[0048] Figure 3 This is a schematic diagram of an optional load balancing test apparatus according to an embodiment of this application;
[0049] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0050] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0051] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] According to one aspect of the embodiments of this application, a method embodiment for testing load balancing is provided, which is applied to load balancing testing applications.
[0053] Optionally, in this embodiment, the above-described load balancing testing method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal 101 and server 103. Figure 1 As shown, server 103 connects to terminal 101 via a network and can be used to provide services (such as game services, application services, etc.) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services to server 103. The aforementioned network includes, but is not limited to, wide area networks (WANs), metropolitan area networks (MANs), or local area networks (LANs). Terminal 101 is not limited to PCs, mobile phones, tablets, etc. The load balancing test method of this application embodiment can be executed by server 103, by terminal 101, or by both server 103 and terminal 101. The load balancing test method of this application embodiment can also be executed by a client installed on terminal 101.
[0054] Figure 2 This is a flowchart of an optional load balancing test method according to an embodiment of this application, such as... Figure 2 As shown, the method may include the following steps:
[0055] Step S202: Create an initial test scenario based on the target system parameters of the load balancer, wherein the initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers;
[0056] Step S204: Adjust the scenario parameters of the initial test scenario according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and the set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold.
[0057] Step S206: Test the load balancer in the target test scenario and obtain the test results.
[0058] Through steps S202 to S206 above, the load balancing test application creates an initial test scenario based on the target system parameters of the load balancing system. The scenario parameters of the initial test scenario are then adjusted based on the first resource utilization rate of the load balancing system to obtain the target test scenario. This ensures that the second resource utilization rate of the load balancing system in the target test scenario is higher than or equal to the resource utilization threshold. Using the target test scenario for automated load balancing testing saves human resources, eliminates reliance on testers' experience during the testing process, reduces factors affecting test results, and achieves the goal of increasing testing speed through automated testing. This improves the testing efficiency of the load balancing testing process and solves the technical problem of low testing efficiency in the load balancing testing process.
[0059] In the technical solution provided in step S202, the load balancing test application can be, but is not limited to, any application with load balancing test function implemented in any form, such as: plugins, clients, mini-programs, cloud service software, application software, etc.
[0060] Optionally, in this embodiment, a load balancer is a network service device that distributes traffic across multiple backend servers. Through traffic distribution, it can quickly improve the external service capabilities of an application system. The aforementioned load balancer may include, but is not limited to, Layer 7 load balancing. Layer 7 load balancing operates at the application layer of the OSI model (Open System Interconnection Reference Model) and is based on virtual URLs (Uniform Resource Locators) or host IPs (Internet Protocol).
[0061] Optionally, in this embodiment, the target system parameters for load balancing may be, but are not limited to, parameters describing the scale of load balancing, such as the number of processor cores, etc.
[0062] Optionally, in this embodiment, the load balancing test environment includes: a client, a load balancer to be tested, and a server connected in sequence. The client is used to send traffic to the load balancer to be tested, and the load balancer to be tested is used to distribute the traffic sent by the client to the server. The load balancer is tested during this traffic reception and distribution process.
[0063] As an optional implementation, creating an initial test scenario based on the target system parameters of the load balancer includes:
[0064] S11, Create a first number of virtual machines according to the target system parameters of load balancing to obtain the initial client set and the initial server set;
[0065] S12, connect the initial client set to the load balancer, and attach the initial server set to the backend of the load balancer, thereby obtaining the initial client set, the load balancer and the initial server set connected in sequence;
[0066] S13, perform connectivity verification on the initially connected client set, the load balancer and the initial server set;
[0067] S14, if the connectivity verification of the sequentially connected initial client set, the load balancer and the initial server set passes, the sequentially connected initial client set, the load balancer and the initial server set are determined as the initial test scenario.
[0068] Optionally, in this embodiment, the first number of virtual machines may, but is not limited to, be created on a cloud server. The load balancing test application creates a test environment on the cloud server to test the load balancing.
[0069] Optionally, in this embodiment, a portion of the first number of virtual machines serves as the initial client set, and another portion serves as the initial server set.
[0070] Optionally, in this embodiment, connectivity verification is performed on the initially connected client set, load balancer and initial server set. Once the verification is successful, it is determined that the initial test scenario has been created, thereby ensuring that the client, load balancer and server can work normally during the test.
[0071] As an optional implementation, a first number of virtual machines are created on a cloud server according to the target system parameters for load balancing, resulting in the initial client set and the initial server set, which include:
[0072] S21, obtain the target client number and target server number corresponding to the target system parameters from the system parameters, client number and server number that have a corresponding relationship, wherein the first number is the sum of the target client number and the target server number;
[0073] S22, create virtual machines for the target number of clients, and install testing tools on the virtual machines for the target number of clients to obtain the initial client set;
[0074] S23, create the target number of virtual machines, and install the web service program on the target number of virtual machines to obtain the initial server set.
[0075] Optionally, in this embodiment, the number of clients and servers to be created under different scales can be determined in advance based on the scale of load balancing. During the test, the corresponding number of virtual machines are created by obtaining the target number of clients and the target number of servers through the target system parameters of load balancing.
[0076] Optionally, in this embodiment, the first quantity is the sum of the number of target clients and the number of target servers. One way to create the first quantity of virtual machines is to create the first quantity of virtual machines, configure the virtual machines for the target number of clients as clients, and configure the virtual machines for the target number of servers as servers. Another way is to create the target number of virtual machines for the target number of clients and configure them as clients, and create the target number of virtual machines for the target number of servers and configure them as servers.
[0077] Optionally, in this embodiment, the testing tools mentioned above may include, but are not limited to, various testing tools with load balancing testing functions. For example, HTTP / HTTPS testing tools (such as Wrk), which is an HTTP stress testing tool. The client may be set to start automatically on boot, but is not limited to.
[0078] Optionally, in this embodiment, the web service program may include, but is not limited to, various types of web service programs, such as the web service program Nginx, which is a high-performance HTTP server and reverse proxy server. The server may, but is not limited to, be configured to start automatically on boot.
[0079] In the technical solution provided in step S204, the resource utilization rate of the load balancer may include, but is not limited to, the utilization rate of various resources on the load balancer. For example, the resource utilization rate of the load balancer may be the CPU utilization rate of the load balancer. The first resource utilization rate may be, but is not limited to, the CPU utilization rate of the load balancer in the initial test scenario. The second resource utilization rate may be, but is not limited to, the CPU utilization rate of the load balancer in the target test scenario.
[0080] Optionally, in this embodiment, the scenario parameters may include, but are not limited to, any adjustable parameters in the test scenario. For example, the number of clients, the number of client threads, the number of client connections, the number of servers, etc.
[0081] Optionally, in this embodiment, the resource utilization threshold may be, but is not limited to, 100%, or a value close to 100%, such as 98%, 99%, 99.5%, 99.8%, etc.
[0082] As an optional embodiment, adjusting the scenario parameters of the initial test scenario based on the first resource utilization rate of the load balancer includes:
[0083] S31, during the process of increasing the load balancer in the initial test scenario, the first resource utilization rate of the load balancer in the initial test scenario is detected.
[0084] S32, if the first resource utilization rate is detected to be lower than the resource utilization rate threshold, the scenario parameters of the initial test scenario are adjusted until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold.
[0085] S33, the test scenario under the second resource utilization rate is determined as the target test scenario.
[0086] Optionally, in this embodiment, if the first resource utilization rate is detected to be lower than the resource utilization rate threshold, the scenario parameters of the initial test scenario can be repeatedly adjusted until the second resource utilization rate is detected to meet the requirement of being higher than or equal to the resource utilization rate threshold.
[0087] Optionally, in this embodiment, the process of adjusting scene parameters may include, but is not limited to, adjusting multiple parameters in turn.
[0088] As an optional embodiment, during the process of stressing the load balancer in the initial test scenario, detecting the first resource utilization rate of the load balancer in the initial test scenario includes:
[0089] S41, create an initial virtual machine and add the initial client set to the client group of the initial virtual machine to obtain the target virtual machine as the control terminal of the initial test scenario;
[0090] S42, In the initial test scenario, the load balancer is subjected to increased pressure;
[0091] S43, under the condition of increasing pressure in the first moment, monitor the first resource utilization of the load balancer through the target virtual machine.
[0092] Optionally, in this embodiment, the target virtual machine is the control terminal of the initial test scenario. Adding the initial client set to the client group of the initial virtual machine can enable the target virtual machine to know which clients need to be controlled in the initial test scenario.
[0093] Optionally, in this embodiment, the load balancer in the initial test scenario is subjected to pressure for a period of time (first time) before the target virtual machine is used to monitor the first resource utilization of the load balancer.
[0094] Optionally, in this embodiment, the target virtual machine can, but is not limited to, use operation and maintenance tools (such as Ansible) to manage clients and servers in batches.
[0095] As an optional embodiment, adjusting the scenario parameters of the initial test scenario until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold includes:
[0096] S51, adjust the performance parameters of the initial client set from the first parameter to the second parameter to obtain the intermediate client set;
[0097] S52, if the resource utilization rate of the test scenario including the intermediate client set is lower than the resource utilization rate threshold but the number of timeout messages of the intermediate client set exceeds the target number, the number of clients in the intermediate client set is adjusted from the second number to the third number, and / or the number of servers in the initial server set is adjusted from the fourth number to the fifth number to obtain the intermediate test scenario;
[0098] S53, Test the intermediate test scenario including a client set with a target performance parameter, wherein the target performance parameter is the maximum performance parameter reached by the initial client set when no timeout message occurs during the process of adjusting the performance parameter of the initial client set from the first parameter to the second parameter;
[0099] S54, if it is detected that the resource utilization of the intermediate test scenario, which includes a set of clients with target performance parameters, is lower than the resource utilization threshold, the performance parameters of the intermediate test scenario with the maximum performance parameters are adjusted.
[0100] Optionally, in this embodiment, the performance parameters of the initial client set may include, but are not limited to, the number of processes, the number of connections, etc.
[0101] Optionally, in this embodiment, the process of adjusting the scene parameters may, but is not limited to, adjusting the performance parameters of the client set, the number of virtual machines (including the number of clients, and / or the number of servers) in turn.
[0102] Optionally, in this embodiment, the occurrence of a large number of timeout messages is likely due to an insufficient number of clients. The number of clients can be adjusted first, or the number of servers can be adjusted, or both the number of clients and the number of servers can be adjusted simultaneously.
[0103] In the technical solution provided in step S206, load balancing testing may include, but is not limited to, performance testing and stress testing. Performance testing mainly uses testing tools to simulate various normal, peak, and abnormal load conditions to test various performance indicators of the system. Stress testing, which is testing to obtain the maximum service level that the system can provide, is also a type of performance testing.
[0104] Optionally, in this embodiment, load balancing can be tested by running a test program, and various parameters and indicators can be statistically recorded during the test to obtain test results.
[0105] As an optional embodiment, testing the load balancer in the target test scenario includes:
[0106] S61, Perform a stress test on the load balancer in the target test scenario;
[0107] S62, During the stress test, the test indicators of the target test scenario are statistically analyzed and recorded to obtain the test results.
[0108] Optionally, in this embodiment, the test process automatically executed by the load balancing test application can acquire various parameters and indicators of the test scenario during the test.
[0109] Optionally, in this embodiment, the test metrics for the target test scenario may include, but are not limited to, various metrics that can reflect the performance of load balancing. For example: CPS (Connections Per Second), QPS (Query Per Second), and Latency. CPS may be used, but is not limited to, to represent the number of HTTP / HTTPS requests that can be completed per second, and Latency may be used, but is not limited to, to represent the time from when the client sends a request to when the client receives a response.
[0110] As an optional embodiment, the process of stress testing the load balancer in the target test scenario further includes:
[0111] S71, monitor the process identifier of the load balancer;
[0112] S72, if an abnormal interruption is detected in the load balancing process, the stress test is stopped.
[0113] Optionally, in this embodiment, if an abnormal process interruption is detected during the test, the stress test is stopped and the current state is preserved in order to find and fix the bug.
[0114] This application also provides an optional embodiment, which offers an automated stress testing application for Layer 7 load balancing, relating to the field of software testing technology. This application streamlines online testing processes, fully automating the entire testing phase, saving labor costs, and improving testing efficiency. After testing begins using this application, an initial number of clients and servers are batch-controlled to apply load to the load balancing system, monitoring its CPU utilization. If CPU utilization is detected to be lower than expected, the performance parameters of the testing tools on the clients, such as the number of threads and connections, are increased. If the CPU utilization of the load balancing system still does not meet requirements after traffic timeouts, a certain number of clients and / or servers are added, and the above steps are repeated until the load balancing system reaches full load and the testing tools do not time out when applying traffic. A stress test is then performed for a certain period, recording the load balancing system's performance metrics. During the stress test, the load balancing process is monitored in real time to check for issues such as memory leaks and abnormal interruptions. This reduces the workload of testers, ensures improved testing efficiency, and avoids errors that may arise from manual monitoring.
[0115] In this optional embodiment, the automated stress testing application described above can, but is not limited to, perform the load balancing stress testing process through the following steps:
[0116] Step 1: Based on the scale of the load balancing system, create a sufficient number of virtual machines as clients and servers. This may include, but is not limited to, the following sub-steps:
[0117] Step 1.1: Create a certain number of virtual machines as clients and servers. On the clients, install an HTTP / HTTPS testing tool (such as Wrk), and on the servers, install a web service program such as Nginx and set it to start automatically on boot.
[0118] Step 1.2: Maintain connectivity between the client and the load balancer by mounting the server on the backend of the load balancer system.
[0119] Step 1.3, verify connectivity and establish a test scenario of client-load balancer-server.
[0120] Step 2: Create a virtual machine as the control terminal to manage clients and servers in batches and monitor the CPU utilization of the load balancer. This may include, but is not limited to, the following sub-steps:
[0121] Step 2.1: Create a virtual machine as the control terminal, install operation and maintenance software (such as Ansible) to manage clients and servers in batches, and add the initial number of N clients to the client group of the virtual machine.
[0122] Step 2.2: Automatically execute the test program, monitor the CPU utilization of the load balancer, and manage the test tool to apply pressure to N clients simultaneously.
[0123] Step 3: Based on the load balancer's load, dynamically adjust the number of servers and clients, and test performance parameters such as threads and connections to ensure the load balancer's CPU utilization reaches or approaches 100%. This may include, but is not limited to, the following sub-steps:
[0124] Step 3.1: In step 2.2, after performing the stress test for a period of time, if the CPU utilization of the load balancing system is not close to 100%, the parameters of the testing tool, such as the number of threads and connections, are automatically increased, and the stress test is re-executed. If the load balancing still does not reach full load and there are no timeout messages after increasing the performance parameters, the performance parameters of the testing tool are further increased; however, if a large number of message timeouts occur, step 3.2 is executed.
[0125] Step 3.2: Automatically add M clients to the client group, and batch control N+M clients to run the test tool under load. The test tool uses the maximum performance parameters used when no packet timeout occurs, and continues to monitor the CPU utilization of the load balancing system. If the CPU utilization of the load balancing system still does not reach full load, repeat step 3.1; otherwise, proceed to step 4.
[0126] Step 4: During the stress test, monitor the load balancing process, detect any abnormal interruptions, and statistically record the load balancing performance metrics. This may include, but is not limited to, the following sub-steps:
[0127] Step 4.1: Through step 3, the number of clients and the parameters of the testing tool can be determined so that the CPU utilization of the load balancer reaches or approaches 100% and there will be no packet timeout. Using the determined number of clients and the parameters of the testing tool, the testing tool continuously loads the load balancer to maintain full load.
[0128] Step 4.2: During the flow test, monitor the process ID of the load balancing system. If the process is abnormally interrupted during the test, stop the test; otherwise, proceed to step 4.3.
[0129] Step 4.3: During the test, based on the results returned by the test tool, calculate and record the load balancer's CPS, QPS, and Latency metrics.
[0130] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0131] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause an electronic device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0132] According to another aspect of the embodiments of this application, a load balancing test apparatus for implementing the above-described load balancing test method is also provided, which is applied to load balancing test applications. Figure 3 This is a schematic diagram of an optional load balancing test apparatus according to an embodiment of this application, as shown below. Figure 3 As shown, the device may include:
[0133] Module 32 is used to create an initial test scenario based on the target system parameters of the load balancer. The initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers.
[0134] The adjustment module 34 is used to adjust the scenario parameters of the initial test scenario according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and a set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold.
[0135] The test module 36 is used to test the load balancer in the target test scenario and obtain test results.
[0136] It should be noted that the creation module 32 in this embodiment can be used to execute step S202 in this application embodiment, the adjustment module 34 in this embodiment can be used to execute step S204 in this application embodiment, and the test module 36 in this embodiment can be used to execute step S206 in this application embodiment.
[0137] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of a device, can operate in environments such as... Figure 1 The hardware environment shown can be implemented either through software or through hardware.
[0138] Through the modules described above, the load balancing test application creates an initial test scenario based on the target system parameters of the load balancer. The scenario parameters are then adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. This ensures that the second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization threshold. Using the target test scenario for automated load balancing testing saves manpower, eliminates reliance on tester experience, and reduces factors affecting test results. This achieves the goal of increasing test speed through automation, thereby improving the testing efficiency of the load balancing testing process and solving the technical problem of low testing efficiency.
[0139] As an optional embodiment, the creation module includes:
[0140] A creation unit is used to create a first number of virtual machines based on the target system parameters for load balancing, thereby obtaining the initial client set and the initial server set.
[0141] The first processing unit is configured to connect the initial client set to the load balancer and attach the initial server set to the backend of the load balancer, thereby obtaining the initial client set, the load balancer and the initial server set connected in sequence.
[0142] A verification unit is used to perform connectivity verification on the initial client set, the load balancer and the initial server set that are connected sequentially.
[0143] The first determining unit is configured to determine the initially connected initial client set, the load balancer, and the initial server set as the initial test scenario if the connectivity verification of the sequentially connected initial client set, the load balancer, and the initial server set passes.
[0144] As an optional embodiment, the creation unit is used for:
[0145] The target number of clients and the target number of servers corresponding to the target system parameters are obtained from the system parameters, the number of clients and the number of servers that have a corresponding relationship, wherein the first number is the sum of the number of target clients and the number of target servers;
[0146] Create virtual machines with the target number of clients, and install testing tools on the virtual machines with the target number of clients to obtain the initial client set;
[0147] Create the target number of virtual machines, and install a web service program on the target number of virtual machines to obtain the initial server set.
[0148] As an optional embodiment, the adjustment module includes:
[0149] The detection unit is used to detect the first resource utilization rate of the load balancer in the initial test scenario during the process of applying pressure to the load balancer in the initial test scenario.
[0150] An adjustment unit is configured to adjust the scenario parameters of the initial test scenario when the first resource utilization rate is detected to be lower than the resource utilization rate threshold, until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold.
[0151] The second determining unit is used to determine the test scenario under the second resource utilization rate as the target test scenario.
[0152] As an optional embodiment, the detection unit is used for:
[0153] An initial virtual machine is created, and the initial client set is added to the client group of the initial virtual machine to obtain the target virtual machine as the control terminal of the initial test scenario;
[0154] In the initial test scenario, the load balancer is subjected to increased pressure.
[0155] When pressure is applied immediately, the utilization rate of the first resource of the load balancer is monitored through the target virtual machine.
[0156] As an optional embodiment, the adjustment unit is used for:
[0157] The performance parameters of the initial client set are adjusted from the first parameter to the second parameter to obtain the intermediate client set;
[0158] If the resource utilization of the test scenario including the intermediate client set is lower than the resource utilization threshold but the number of timeout messages of the intermediate client set exceeds the target number, the number of clients in the intermediate client set is adjusted from the second number to the third number, and / or the number of servers in the initial server set is adjusted from the fourth number to the fifth number to obtain the intermediate test scenario.
[0159] The intermediate test scenario includes a set of clients with a target performance parameter, wherein the target performance parameter is the maximum performance parameter reached by the initial client set when no timeout message occurs during the process of adjusting the performance parameter of the initial client set from the first parameter to the second parameter;
[0160] If the resource utilization of the intermediate test scenario, which includes a set of clients with the target performance parameter, is found to be lower than the resource utilization threshold, the performance parameter of the intermediate test scenario with the maximum performance parameter is adjusted.
[0161] As an optional embodiment, the test module includes:
[0162] The test unit is used to perform stress tests on the load balancer in the target test scenario.
[0163] The second processing unit is used to statistically analyze and record the test indicators of the target test scenario during the stress test, and obtain the test results.
[0164] As an optional embodiment, the device further includes:
[0165] The monitoring unit is used to monitor the process identifier of the load balancer during the stress test of the load balancer in the target test scenario.
[0166] The stop unit is used to stop the stress test if an abnormal interruption is detected in the load balancing process.
[0167] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of a device, can operate in environments such as... Figure 1 The hardware environment shown can be implemented through software or hardware, and the hardware environment includes the network environment.
[0168] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described load balancing test method is also provided.
[0169] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application, such as... Figure 4 As shown, the electronic device may include: one or more (only one is shown in the figure) processors 401, memory 403, and transmission devices 405, such as... Figure 4 As shown, the electronic device may also include input / output devices 407.
[0170] The memory 403 can be used to store software programs and modules, such as the program instructions / modules corresponding to the load balancing test method and apparatus in this embodiment. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 403, thereby realizing the aforementioned load balancing test method. The memory 403 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 403 may further include memory remotely located relative to the processor 401, and these remote memories can be connected to electronic devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0171] The aforementioned transmission device 405 is used to receive or send data via a network, and can also be used for data transfer between the processor and memory. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 405 includes a Network Interface Controller (NIC), which can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 405 is a radio frequency (RF) module used for wireless communication with the Internet.
[0172] Specifically, memory 403 is used to store application programs.
[0173] The processor 401 can invoke the application program stored in the memory 403 via the transmission device 405 to perform the following steps:
[0174] An initial test scenario is created based on the target system parameters of the load balancer, wherein the initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers;
[0175] The scenario parameters of the initial test scenario are adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and the set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold.
[0176] The load balancer was tested in the target test scenario, and the test results were obtained.
[0177] This application provides a load balancing testing scheme. An initial test scenario is created using a load balancing testing application based on the target system parameters of the load balancer. The scenario parameters are then adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. This target test scenario ensures that the second resource utilization rate of the load balancer in the target test scenario is higher than or equal to a resource utilization threshold. Automated testing of the load balancer using the target test scenario saves manpower, eliminates reliance on tester experience, and reduces factors affecting test results. This achieves the goal of increasing testing speed through automation, thereby improving the testing efficiency of the load balancing testing process and solving the technical problem of low testing efficiency in the load balancing testing process.
[0178] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0179] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. The electronic device can be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other electronic devices. Figure 4 This does not limit the structure of the aforementioned electronic device. For example, the electronic device may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.
[0180] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware of an electronic device. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0181] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to execute program code for a load balancing test method.
[0182] Optionally, in this embodiment, the storage medium may be located on at least one of the multiple network devices in the network shown in the above embodiment.
[0183] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
[0184] An initial test scenario is created based on the target system parameters of the load balancer, wherein the initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers;
[0185] The scenario parameters of the initial test scenario are adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and the set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold.
[0186] The load balancer was tested in the target test scenario, and the test results were obtained.
[0187] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0188] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0189] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0190] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0191] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0192] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0193] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0194] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0195] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A load balancing testing method, characterized in that, The method, applied to load balancing testing applications, includes: An initial test scenario is created based on the target system parameters of the load balancer, wherein the initial test scenario includes an initial set of clients connected sequentially, the load balancer and the initial set of servers; The scenario parameters of the initial test scenario are adjusted according to the first resource utilization rate of the load balancer to obtain the target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and the set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to the resource utilization rate threshold. The load balancer was tested in the target test scenario, and the test results were obtained. Adjusting the scenario parameters of the initial test scenario based on the first resource utilization rate of the load balancer includes: During the process of increasing the load balancer in the initial test scenario, the first resource utilization rate of the load balancer in the initial test scenario is detected. If the first resource utilization rate is detected to be lower than the resource utilization rate threshold, the scenario parameters of the initial test scenario are adjusted until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold. The test scenario under the second resource utilization rate is determined as the target test scenario; Adjusting the scenario parameters of the initial test scenario until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold includes: The performance parameters of the initial client set are adjusted from the first parameter to the second parameter to obtain the intermediate client set; If the resource utilization of the test scenario including the intermediate client set is lower than the resource utilization threshold but the number of timeout messages of the intermediate client set exceeds the target number, the number of clients in the intermediate client set is adjusted from the second number to the third number, and / or the number of servers in the initial server set is adjusted from the fourth number to the fifth number to obtain the intermediate test scenario. The intermediate test scenario includes a set of clients with a target performance parameter, wherein the target performance parameter is the maximum performance parameter reached by the initial client set when no timeout message occurs during the process of adjusting the performance parameter of the initial client set from the first parameter to the second parameter; If the resource utilization of the intermediate test scenario, which includes a set of clients with the target performance parameter, is found to be lower than the resource utilization threshold, the performance parameter of the intermediate test scenario with the maximum performance parameter is adjusted.
2. The method according to claim 1, characterized in that, Creating an initial test scenario based on the target system parameters for load balancing includes: A first number of virtual machines are created based on the target system parameters for load balancing, thereby obtaining the initial client set and the initial server set. The initial client set is connected to the load balancer, and the initial server set is attached to the backend of the load balancer, resulting in the initial client set, the load balancer, and the initial server set connected in sequence. Connectivity verification is performed on the initial client set, the load balancer, and the initial server set that are connected sequentially. If the connectivity verification of the sequentially connected initial client set, the load balancer, and the initial server set passes, the sequentially connected initial client set, the load balancer, and the initial server set will be determined as the initial test scenario.
3. The method according to claim 2, characterized in that, Based on the target system parameters for load balancing, a first number of virtual machines are created on the cloud server, resulting in the initial client set and the initial server set, which include: The target number of clients and the target number of servers corresponding to the target system parameters are obtained from the system parameters, the number of clients and the number of servers that have a corresponding relationship, wherein the first number is the sum of the number of target clients and the number of target servers; Create virtual machines with the target number of clients, and install testing tools on the virtual machines with the target number of clients to obtain the initial client set; Create the target number of virtual machines, and install a web service program on the target number of virtual machines to obtain the initial server set.
4. The method according to claim 1, characterized in that, During the process of increasing the load balancer's pressure in the initial test scenario, detecting the first resource utilization rate of the load balancer in the initial test scenario includes: An initial virtual machine is created, and the initial client set is added to the client group of the initial virtual machine to obtain the target virtual machine as the control terminal of the initial test scenario; In the initial test scenario, the load balancer is subjected to increased pressure. When pressure is applied immediately, the utilization rate of the first resource of the load balancer is monitored through the target virtual machine.
5. The method according to claim 1, characterized in that, Testing the load balancer in the target test scenario includes: The load balancer is subjected to stress testing in the target test scenario. During the stress test, the test metrics of the target test scenario are statistically analyzed and recorded to obtain the test results.
6. The method according to claim 5, characterized in that, During the stress test of the load balancer in the target test scenario, the method further includes: Monitor the process identifier of the load balancer; If an abnormal interruption is detected in the load balancing process, the stress test shall be stopped.
7. A load balancing testing device, characterized in that, The device, used for load balancing testing applications, includes: A creation module is used to create an initial test scenario based on the target system parameters of the load balancer. The initial test scenario includes an initial set of clients connected sequentially, the load balancer, and an initial set of servers. An adjustment module is used to adjust the scenario parameters of the initial test scenario according to the first resource utilization rate of the load balancer to obtain a target test scenario. The first resource utilization rate is used to indicate the resource utilization rate of the load balancer in the initial test scenario. The target test scenario includes a set of target clients connected in sequence, the load balancer and a set of target servers. The second resource utilization rate of the load balancer in the target test scenario is higher than or equal to a resource utilization rate threshold. The testing module is used to test the load balancer in the target test scenario and obtain test results. The adjustment module is also used for: During the process of increasing the load balancer in the initial test scenario, the first resource utilization rate of the load balancer in the initial test scenario is detected. If the first resource utilization rate is detected to be lower than the resource utilization rate threshold, the scenario parameters of the initial test scenario are adjusted until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold. The test scenario under the second resource utilization rate is determined as the target test scenario; Adjusting the scenario parameters of the initial test scenario until the second resource utilization rate is detected to be higher than or equal to the resource utilization rate threshold includes: The performance parameters of the initial client set are adjusted from the first parameter to the second parameter to obtain the intermediate client set; If the resource utilization of the test scenario including the intermediate client set is lower than the resource utilization threshold but the number of timeout messages of the intermediate client set exceeds the target number, the number of clients in the intermediate client set is adjusted from the second number to the third number, and / or the number of servers in the initial server set is adjusted from the fourth number to the fifth number to obtain the intermediate test scenario. The intermediate test scenario includes a set of clients with a target performance parameter, wherein the target performance parameter is the maximum performance parameter reached by the initial client set when no timeout message occurs during the process of adjusting the performance parameter of the initial client set from the first parameter to the second parameter; If the resource utilization of the intermediate test scenario, which includes a set of clients with the target performance parameter, is found to be lower than the resource utilization threshold, the performance parameter of the intermediate test scenario with the maximum performance parameter is adjusted.
8. A storage medium, characterized in that, The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 6 when it is run.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the method described in any one of claims 1 to 6 via the computer program.
Citation Information
Patent Citations
Method, system, device and medium for automatically testing load balancing cluster performance
CN111158989A
Server complete machine performance comparison test method and device, equipment and medium
CN112506751A