A method and device for server load testing
By configuring the corresponding relationship between the domain name of the server to be tested and the number of requests, the problem of insufficient load-bearing capacity of the load balancing server is solved, server load testing without load balancing is realized, and the accuracy of the test results and the reliability of multiple servers are improved. Load stress testing capabilities.
Patent Information
- Application Number
- CN202210270312.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-03-18
AI Technical Summary
The insufficient carrying capacity of existing load balancing servers reduces the accuracy of server load test results, making it difficult to maximize the load bearing capacity of the server under test.
By configuring the corresponding relationship between the domain names and the number of requests for multiple servers under test, requests are sent to each server under test, and the load test results are determined based on the response results to achieve testing of different load pressures.
When there is no load balancing server or there is a shortage of load balancing servers, it can improve the accuracy of server load testing, enable testing of different load pressures on the server to be tested, and improve the ideality of the test results.
Smart Images

Figure CN114629888B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method and device for server load testing. Background Art
[0002] With the development of computer technology, servers have been widely used. Usually, servers have the ability to respond to service requests, provide services, and guarantee services, and provide computing or application services to other clients in the network. It is usually necessary to perform load testing on the server.
[0003] Currently, load balancing is usually used to perform load testing on servers. However, if the load balancing server's carrying capacity is insufficient to meet the needs of the server under test, the server under test will not be able to exert its maximum load bearing capacity during the load test on the server. Testing using the above method may lack test data when the server under test exerts its maximum load bearing capacity, thus reducing the accuracy of the test results. Summary of the invention
[0004] In view of this, the present application provides a method and apparatus for server load testing to improve the accuracy of server load testing results.
[0005] In a first aspect, the present application provides a method for server load testing, the method comprising:
[0006] Configure the domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested correspond to each other;
[0007] According to the domain name of each server to be tested, send requests to each server to be tested respectively;
[0008] The load test results of each server under test are determined according to the response of each server under test to the request.
[0009] In a possible implementation, the domain name of each server to be tested among the multiple servers to be tested is configured, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested, including:
[0010] Configure a correspondence between the IP address and the domain name of each server to be tested among multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested are corresponding;
[0011] Before sending requests to each server to be tested according to the domain name of each server to be tested, the following is also included:
[0012] The domain name of each server to be tested is determined according to the IP address of each server to be tested and the corresponding relationship between the IP address and the domain name of each server to be tested.
[0013] In a possible implementation, the load test result includes: one or more of the response time, response speed, and number of transactions processed per second (TPS) of the server.
[0014] In a possible implementation, the request sent to each server to be tested includes a Hypertext Transfer Protocol request HTTP request;
[0015] The response of each server to be tested to the request includes a Hypertext Transfer Protocol response (HTTP response).
[0016] In a second aspect, the present application provides a device for server load testing, the device comprising:
[0017] A domain name configuration unit, used to configure the domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested;
[0018] A request sending unit, used to send requests to each server to be tested according to the domain name of each server to be tested;
[0019] The result determination unit is used to determine the load test result of each server to be tested according to the response of each server to be tested to the request.
[0020] In a possible implementation, the device further includes a correspondence configuration unit, which is used to configure a correspondence between an IP address and a domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested are corresponding;
[0021] The domain name configuration unit is used to determine the domain name of each server to be tested according to the IP address of each server to be tested and the corresponding relationship between the IP address and the domain name of each server to be tested.
[0022] In a possible implementation, the load test result includes: one or more of the response time, response speed, and number of transactions processed per second (TPS) of the server.
[0023] In a possible implementation, the request sent to each server to be tested includes a Hypertext Transfer Protocol request HTTP request;
[0024] The response of each server to be tested to the request includes a Hypertext Transfer Protocol response (HTTP response).
[0025] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a code, and the processor is used to call the code stored in the memory to execute any of the above methods.
[0026] In a fourth aspect, the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute any of the above methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a flow chart of a method for server load testing provided by an embodiment of the present application;
[0028] Figure 2 A schematic diagram of a load test of multiple servers provided in an embodiment of the present application;
[0029] Figure 3 It is a structural schematic diagram of a device for server load testing provided in an embodiment of the present application;
[0030] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] Currently, load balancing is usually used to perform load testing on servers. However, if the load balancing server's carrying capacity is insufficient to meet the needs of the server under test, the server under test will not be able to exert its maximum load bearing capacity during the load test on the server. Testing using the above method may lack test data when the server under test exerts its maximum load bearing capacity, thus reducing the accuracy of the test results.
[0032] Based on this, in the embodiments of the present application provided by the applicant,
[0033] By adopting the technical solution of the embodiment of the present application, it is possible to perform server load testing in the absence of a load balancing server or in the absence of a load balancing server, and it is possible to send different numbers of requests to servers to be tested with different test requirements to achieve different load tests. Since the domain name of each server to be tested and the number of requests sent to each server to be tested correspond to each other, it is possible to test different load pressures of the server to be tested, thereby improving the accuracy of the test results and obtaining relatively ideal test results.
[0034] A load-balancing server is a server that distributes load. Through the load-balancing server, service requests are evenly distributed to the services actually executed, thereby adjusting indicators such as the response speed of the entire system.
[0035] Load testing refers to sending requests to a server and testing the server's operating conditions based on the server's response to the request. Stress testing usually refers to testing after increasing the server's load to a certain extent, for example, to test the server's operation under a large load pressure.
[0036] The server load testing method provided in the embodiment of the present application is also applicable to server stress testing, and the implementation principle is similar, so the embodiment of the present application will not be described in detail.
[0037] In order to facilitate understanding of the technical solution provided by the embodiment of the present application, a method and device for server load testing provided by the embodiment of the present application are described below in conjunction with the accompanying drawings.
[0038] Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. Based on the embodiments in the present application, other embodiments obtained by those skilled in the art without making creative contributions are all within the scope of protection of the present application.
[0039] In the claims and specification and drawings of this application, the terms "includes" and "has" and any variations thereof are intended to cover non-exclusive inclusions.
[0040] The present application provides a method for server load testing.
[0041] See also Figure 1 , Figure 1 It is a flow chart of the server load testing method provided in an embodiment of the present application.
[0042] like Figure 1 As shown, the method for server load testing in the embodiment of the present application includes S101-S103.
[0043] S101: configuring a domain name of each server to be tested among multiple servers to be tested, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested.
[0044] Domain Name: Domain Name, also known as network domain. A domain name is usually a string of names separated by dots, which is the name of a computer or computer group on the Internet. It is used to locate the computer during data transmission (sometimes also refers to the geographical location).
[0045] There are usually multiple servers to be tested, and a domain name is configured for each server to be tested.
[0046] The domain name configured for each server to be tested can be the same or different.
[0047] The greater the number of requests sent to the server under test, the greater the pressure on the server under test.
[0048] S102: Sending requests to each server to be tested according to the domain name of each server to be tested.
[0049] The number of requests sent to each server to be tested corresponds to the domain name of each server to be tested.
[0050] Since the domain names of multiple servers (a group of servers) with the same test requirements are set to be the same, a test script can be executed through a thread to send requests to multiple servers in this group, thereby sending requests that meet the test requirements to multiple servers in this group.
[0051] S103: Determine the load test result of each server to be tested according to the response of each server to be tested to the request.
[0052] By adopting the technical solution of the embodiment of the present application, it is possible to perform server load testing in the absence of a load balancing server or in the absence of a load balancing server, and it is possible to send different numbers of requests to servers to be tested with different test requirements to achieve different load tests. Since the domain name of each server to be tested and the number of requests sent to each server to be tested correspond, it is possible to test different load pressures on the servers to be tested, thereby improving the accuracy of the test results.
[0053] For example, suppose we have 100 web servers, and there is only one load balancing server during the load test. Under high load pressure, the central processing unit (CPU) of the load balancing server is always at 100% load, while the CPU of the web server is only 20%-30%. At this time, if you want to obtain the carrying capacity of the server system, or the maximum number of transactions per second (TPS) of the server system, you usually need to add load balancing servers. By adopting the technical solution of the embodiment of the present application, it is possible to test different load pressures of the server to be tested without adding load balancing servers.
[0054] The application also provides another method for server load testing.
[0055] The method for server load testing in the embodiment of the present application includes S201-S204.
[0056] In a possible implementation, nGrinder software is used to write test scripts and related test tools to implement server load testing.
[0057] S201: Configure a correspondence between an IP address and a domain name of each server to be tested among multiple servers to be tested.
[0058] Specifically, according to the test requirements of each server to be tested among the multiple servers to be tested, the corresponding relationship between the IP address and the domain name of each server to be tested is configured.
[0059] The test demand of the server under test refers to the number of requests that need to be sent to the server under test.
[0060] The domain name of each server to be tested and the number of requests sent to each server to be tested correspond to each other.
[0061] The domain name of each server to be tested is determined according to the number of requests sent to each server to be tested.
[0062] IP address: Internet Protocol Address, also known as IP. IP address refers to the Internet Protocol address, also translated as Internet Protocol address. IP address is a unified address format provided by the IP protocol. It assigns a logical address to each network and each host on the Internet to shield the difference in physical addresses.
[0063] The request sent to each server under test can be an HTTP request. The HTTP protocol is an application layer protocol based on the TCP protocol. The full name is Hypertext Transfer Protocol. It is a request-response protocol. The HTTP Request is the request sent by the client to the Web server.
[0064] The response returned by the server can be an HTTP response (HTTP Response). HTTP Response is the response returned by the Web server to the client.
[0065] Taking the number of servers to be tested as 100 as an example, load testing is performed on 100 servers.
[0066] Configure the correspondence between the IP addresses and domain names of 100 servers to be tested. The domain names can be customized.
[0067] Specifically, add hosts in the code configuration page of nGrinder software.
[0068] Hosts refers to a system file without an extension, which is used to associate domain names with IP addresses.
[0069] nGrinder is a performance testing system based on Grinder that is very easy to manage and use.
[0070] Grinder is an open source Java load testing framework and a distributed stress testing tool.
[0071] nGrinder is an application for running test scripts written in jython (python-like) or groovy (java-like) on multiple machines. nGrinder consists of a controller and multiple agents connected to it. Users can manage and control tests and view reports through the web interface. The controller will distribute the tests to one or more agents for execution. nGrinder supports mainstream development languages for test script development. The controller distributes the scripts and required resources to the agent for execution. During the execution process, it sends HTTP Request to the target server and collects indicators such as the target server's operating status, the number of transactions per second (TPS), and the response time based on the HTTP Response returned by the target server.
[0072] For example, if the domain name is ngrinder-test.com, the configuration on the code configuration page of nGrinder software is as follows:
[0073] ip1 ngrinder-test.com
[0074] ip2ngrinder-test.com
[0075] ip3ngrinder-test.com
[0076] …
[0077] ip99ngrinder-test.com
[0078] ip100ngrinder-test.com
[0079] Among them, ip1 ngrinder-test.com means that the IP address of the first server is ip1 and the domain name is ngrinder-test.com.
[0080] Each server under test has its own IP address.
[0081] In a possible implementation, the correspondence between the IP addresses and domain names of the multiple servers to be tested is configured according to the test requirements of the multiple servers to be tested.
[0082] In some scenarios, different loads need to be applied to different servers. For example, 30 of 100 servers (the first group of servers) need to receive 30% of all requests, 50 servers (the second group of servers) need to receive 20% of all requests, and 20 servers (the third group of servers) need to receive 50% of all requests.
[0083] The multiple servers to be tested can be divided into multiple groups. The IP addresses of each group of servers to be tested correspond to the same domain name, and the IP addresses of servers to be tested in different groups correspond to different domain names.
[0084] For example, the domain name corresponding to the first group of servers is ngrinder-test1.com, the domain name corresponding to the second group of servers is ngrinder-test2.com, and the domain name corresponding to the third group of servers is ngrinder-test3.com.
[0085] At this point, the configuration on the code configuration page of the nGrinder software is as follows:
[0086] ip1 ngrinder-test1.com
[0087] ip2 ngrinder-test1.com
[0088] ip3 ngrinder-test1.com
[0089] …
[0090] ip29 ngrinder-test1.com
[0091] ip30 ngrinder-test1.com
[0092] ip31 ngrinder-test2.com
[0093] ip32 ngrinder-test2.com
[0094] …
[0095] ip79 ngrinder-test2.com
[0096] ip80 ngrinder-test2.com
[0097] ip81 ngrinder-test3.com
[0098] ip82 ngrinder-test3.com
[0099] …
[0100] ip99ngrinder-test3.com
[0101] ip100 ngrinder-test3.com
[0102] The first group of servers includes the first server to the 30th server, ip1-ip30 correspond to the IP addresses of the first server to the 30th server respectively, and the domain names of the first server to the 30th server are ngrinder-test1.com;
[0103] The second group of servers includes the 31st server to the 80th server, ip31-ip80 correspond to the IP addresses of the 31st server to the 80th server respectively, and the domain names of the 31st server to the 80th server are ngrinder-test2.com;
[0104] The third group of servers includes the 81st server to the 100th server, ip81-ip100 correspond to the IP addresses of the 81st server to the 100th server respectively, and the domain names of the 81st server to the 100th server are ngrinder-test3.com.
[0105] Just configure the domain name corresponding to the server to be tested in the test script, and allocate the number of requests corresponding to the server to be tested to each thread.
[0106] See also Figure 2 , Figure 2 A schematic diagram of a load test of multiple servers provided in an embodiment of the present application.
[0107] like Figure 2 As shown, thread 1 executes test script 1, and sends requests to the servers to be tested (the first server to the 30th server) with the domain name ngrinder-test1.com, and the number of requests is 30% of the total number of requests; thread 2 executes test script 2, and sends requests to the servers to be tested (the 31st server to the 80th server) with the domain name ngrinder-test2.com, and the number of requests is 20% of the total number of requests; thread 3 executes test script 3, and sends requests to the servers to be tested (the 81st server to the 100th server) with the domain name ngrinder-test3.com, and the number of requests is 50% of the total number of requests. The servers to be tested can be web servers.
[0108] S202: Determine the domain name of each server to be tested according to the IP address of the server to be tested and the correspondence between the IP address of the server to be tested and the domain name.
[0109] S203: Send a request to each of the multiple servers to be tested, wherein the number of requests sent to each server to be tested corresponds to the domain name of each server to be tested.
[0110] Since the domain names of multiple servers (a group of servers) with the same test requirements are set to be the same, a test script can be executed through a thread to send requests to multiple servers in this group, thereby sending requests that meet the test requirements to multiple servers in this group.
[0111] S204: Determine the load test result of each server to be tested according to the response of each server to be tested to the request.
[0112] The load test results of the server to be tested may include performance indicators such as response time, response speed, and TPS.
[0113] By adopting the technical solution of the embodiment of the present application, the test script and related test tools are obtained using the nGrinder software, and server load testing can be performed in the absence of a load balancing server or in the absence of a load balancing server through the hosts method, and different numbers of requests can be sent to servers under test with different test requirements to achieve different load tests, thereby improving the accuracy of the test results. The multi-threaded method and the hosts method can be used to implement batch testing of different load pressures on the servers under test.
[0114] When there are many servers to be tested, it is more complicated to determine the servers to be tested by their IP addresses and send requests to each server. By adopting the technical solution of the embodiment of the present application, the domain names of multiple servers to be tested with the same test requirements are set to the same, which does not require additional resources and is simple to configure.
[0115] The present application also provides a device for server load testing.
[0116] See also Figure 3 , Figure 3 It is a structural diagram of a device for server load testing provided in an embodiment of the present application.
[0117] like Figure 3 As shown, the server load test device 300 in the embodiment of the present application includes: a domain name configuration unit 301, a request sending unit 302 and a result determination unit 303.
[0118] A domain name configuration unit 301 is used to configure the domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested;
[0119] The request sending unit 302 is used to send requests to each server to be tested according to the domain name of each server to be tested;
[0120] The result determination unit 303 is used to determine the load test result of each server to be tested according to the response of each server to be tested to the request.
[0121] In a possible implementation, the device further includes a correspondence configuration unit, which is used to configure a correspondence between an IP address and a domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested are corresponding;
[0122] The domain name configuration unit is used to determine the domain name of each server to be tested according to the IP address of each server to be tested and the corresponding relationship between the IP address and the domain name of each server to be tested.
[0123] In a possible implementation, the load test result includes: one or more of the response time, response speed, and number of transactions processed per second (TPS) of the server.
[0124] In a possible implementation, the request sent to each server to be tested includes a Hypertext Transfer Protocol request HTTP request;
[0125] The response of each server to be tested to the request includes a Hypertext Transfer Protocol response (HTTP response).
[0126] The units included in the above-mentioned server load testing device 300 can achieve the same technical effects as the server load testing method in the above embodiment, and will not be described again here to avoid repetition.
[0127] The present application also provides an electronic device.
[0128] See also Figure 4 , Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0129] like Figure 4 As shown, the electronic device 400 includes a processor 401 and a memory 402, wherein the memory 402 stores codes, and the processor 401 is used to call the codes stored in the memory 402 to execute any of the above methods.
[0130] The units included in the above-mentioned electronic device 400 can achieve the same technical effect as the method of server load testing in the above embodiment, and will not be described again here to avoid repetition.
[0131] In an embodiment of the present application, a computer-readable storage medium is also provided, and the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the above-mentioned server load test method, and can achieve the same technical effect, to avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is such as a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0132] 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 apparent to those skilled in the art, and the general principles defined herein may 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 the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for server load testing, characterized in that: The method comprises: The domain name of each server to be tested in the multiple servers to be tested is configured in the multiple test scripts, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested; the multiple servers to be tested are divided into multiple groups, the domain names corresponding to each server to be tested in a group of servers to be tested are the same, and servers to be tested in different groups correspond to different numbers of requests to be sent; one test script corresponds to a group of servers to be tested; the domain name of each server to be tested is determined according to the number of requests sent to each server to be tested; Executing the test script to send requests to each of the servers to be tested according to the domain name of each of the servers to be tested; Determine the load test results of each server to be tested according to the response of each server to be tested to the request.
2. The method according to claim 1, characterized in that The configuring of the domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested, includes: Configuring a correspondence between an IP address and a domain name of each server to be tested among multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested are corresponding; Before sending requests to each of the servers to be tested respectively according to the domain names of the servers to be tested, the method further includes: The domain name of each server to be tested is determined according to the IP address of each server to be tested and the corresponding relationship between the IP address and the domain name of each server to be tested.
3. The method according to claim 1, characterized in that The load test result includes: one or more of the response time, response speed, and the number of transactions processed per second (TPS) of the server.
4. The method according to claim 1, characterized in that: The request sent to each server to be tested includes a Hypertext Transfer Protocol request (HTTP request); The response of each server to be tested to the request includes a Hypertext Transfer Protocol response HTTP response.
5. A device for server load testing, characterized in that: The device comprises: A domain name configuration unit, used to configure the domain name of each server to be tested in multiple test scripts, wherein the domain name of each server to be tested corresponds to the number of requests sent to each server to be tested; multiple servers to be tested are divided into multiple groups, and the domain names corresponding to each server to be tested in a group of servers to be tested are the same, and servers to be tested in different groups correspond to different numbers of requests to be sent; one test script corresponds to a group of servers to be tested; the domain name of each server to be tested is determined according to the number of requests sent to each server to be tested; A request sending unit, used to execute the test script to send requests to each server to be tested according to the domain name of each server to be tested; The result determination unit is used to determine the load test result of each server to be tested according to the response of each server to be tested to the request.
6. The device according to claim 5, characterized in that The device further comprises a correspondence configuration unit, which is used to configure a correspondence between an IP address and a domain name of each server to be tested among the multiple servers to be tested, wherein the domain name of each server to be tested and the number of requests sent to each server to be tested are corresponding; The domain name configuration unit is used to determine the domain name of each server to be tested according to the IP address of each server to be tested and the corresponding relationship between the IP address and the domain name of each server to be tested.
7. The device according to claim 5, characterized in that The load test result includes: one or more of the response time, response speed, and the number of transactions processed per second (TPS) of the server.
8. The device according to claim 5, characterized in that The request sent to each server to be tested includes a Hypertext Transfer Protocol request (HTTP request); The response of each server to be tested to the request includes a Hypertext Transfer Protocol response HTTP response.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores codes, and the processor is used to call the codes stored in the memory to execute the method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 4.
