CN-122027524-A - Load balancing test method, system and medium based on algorithm identification
Abstract
The invention relates to a load balancing test method, a system and a medium based on algorithm identification, belonging to the technical field of network communication, wherein the method comprises the steps of configuring test cases, setting reverse proxy addresses and at least two source station server addresses; the method comprises the steps of constructing test request flow, inserting an identification field of a load balancing algorithm into a Header of each test request, sending the test request to a reverse proxy address, receiving response flow from a source station server, wherein the Header of the response flow contains a source station identification, verifying whether request distribution is consistent with a set load balancing algorithm strategy according to the source station identification and the load balancing algorithm identification, and generating a load balancing test report. According to the invention, the algorithm identifier is embedded in the request, and the source station identifier is embedded in the response, so that whether the actual distribution behavior of the load balancing algorithm accords with the expectation or not can be verified efficiently, the manual verification dependence is reduced, and the test coverage rate and the result reliability are improved.
Inventors
- WAN JIANGWEN
- HUANG XING
- OU HUAIGU
- WANG XIAOQING
- DING QIAN
Assignees
- 云盾智慧安全科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260212
Claims (10)
- 1. The load balancing test method based on the algorithm identification is characterized by comprising the following steps of: Configuring a test case, and setting a reverse proxy address and at least two source station server addresses; Constructing test request flow, and inserting an identification field of a load balancing algorithm into a Header of each test request, wherein the identification field comprises a polling algorithm identification field, a least connection number algorithm identification field and a universal hash algorithm identification field; Sending a test request carrying a load balancing algorithm identifier to a reverse proxy address; Receiving response traffic from the source station server, wherein a Header of the response traffic contains a source station identifier of the response source station server; and verifying whether the distribution of the request is consistent with a set load balancing algorithm strategy according to the source station identification in the response flow and the load balancing algorithm identification in the test request, and generating a load balancing test report according to a verification result.
- 2. The method of claim 1, wherein configuring the test case and setting the reverse proxy address and the at least two source station server addresses comprises: Setting a reverse proxy address for designating a load balancing service to be tested and at least two source station servers with different network addresses in a predefined configuration template to obtain a use case configuration data template; According to the test requirement, selecting a current reverse proxy to be tested from a case configuration data template to be combined with a source station server, and associating at least one load balancing algorithm to be verified to generate a corresponding test case.
- 3. The method of claim 1, wherein constructing test request traffic and inserting an identification field of a load balancing algorithm in a Header of each test request comprises: generating basic test request flow by taking a reverse proxy address as a request target; Adding a corresponding algorithm identification field for the Header of each basic test request flow according to a load balancing algorithm to be verified, wherein the algorithm identification field comprises a polling algorithm identification field, a least connection number algorithm identification field and a universal hash algorithm identification field; And adding test session parameters including the request number, the concurrent connection number and the connection maintaining time to the Header of the basic test request flow to obtain the final test request flow.
- 4. The method of claim 1, wherein verifying whether the request distribution is consistent with the set load balancing algorithm policy based on the source station identification in the response traffic and the load balancing algorithm identification in the test request, and generating the load balancing test report based on the verification result comprises: counting the source station identifiers in the response flow to obtain the response quantity of each source station server; According to the load balancing algorithm identification in the test request, carrying out matching verification on the actual request distribution and the set load balancing algorithm strategy to obtain a corresponding verification result; generating a load balancing test report according to the verification result and the response quantity of each source station server; The matching verification comprises the steps of verifying whether response proportion of two source station servers is equal to 1 when the algorithm is identified as a polling algorithm, verifying whether requests are distributed to the source station server with the least preset connection number when the algorithm is identified as a least connection number algorithm, and verifying whether requests with the same hash key value are distributed to the same source station server when the algorithm is identified as a universal hash algorithm.
- 5. The method of claim 4, wherein verifying whether the response ratio of the two source servers is equal to 1 when the algorithm is identified as a polling algorithm comprises: transmitting N test requests carrying polling algorithm identification fields to the reverse proxy address so as to averagely distribute the N test requests to the source station server for processing; receiving response flow from each source station server, and counting the source station identifiers carried in the respective response flow to obtain the response quantity of each source station server; Determining the response proportion between the two source station servers according to the response quantity, and judging whether the response proportion is equal to 1; if the total response proportion is equal to 1, judging that the current load balancing strategy accords with a polling algorithm; If the response proportion is not equal to 1, judging that the current load balancing strategy accords with the polling algorithm, and recording the deviation degree of the response proportion in a load balancing test report.
- 6. The method of claim 4, wherein verifying whether the request is distributed to the source station server having the least number of preset connections when the algorithm is identified as the least number of connections algorithm comprises: Transmitting N test requests carrying the least connection number algorithm identification field to the reverse proxy address; distributing N test requests to corresponding source station servers for processing according to the initial long connection number of each source station server; receiving response flow from each source station server, and counting the long connection number according to the source station identification of each response flow to obtain the current long connection number of each source station server; and comparing the current long connection number with the initial long connection number, and judging that the current load balancing algorithm is the minimum connection number algorithm when the comparison result is that the increment of the long connection number of the source station server with the minimum connection number is equal to N and the long connection numbers of the rest source station servers are kept unchanged.
- 7. The method of claim 6, wherein assigning N test requests to corresponding source servers for processing based on the initial number of long connections for each source server comprises: acquiring the initial long connection number of each source station server; when the initial long connection number of one source station server is 0 and the initial long connection number of the rest source station servers is not 0, distributing N test requests to the source station servers with the initial long connection number of 0 for processing; When the initial long connection numbers of all the source station servers are 0 or not 0, a group of random test requests with the long connection request number M are sent to the reverse proxy address, then the long connection number of each source station server is obtained, and N test requests are distributed to the source station server with the minimum long connection number for processing.
- 8. The method of claim 4, wherein verifying whether requests for the same hash key are distributed to the same source server when the algorithm is identified as a universal hash algorithm comprises: transmitting a test request carrying a universal hash algorithm identification field to the reverse proxy address; Receiving response flow from each source station server, and counting source station identifiers carried in the respective response flow to determine the source station server responding to the test request; n test requests carrying the universal hash algorithm identification field are sent to a source station server responding to the test requests, and response flow of the source station server is received to obtain test response numbers; And when the number of the test requests of the source station server responding to the test requests is consistent with the number of the test responses, judging that the current load balancing algorithm is a universal hash algorithm.
- 9. A load balancing test system based on algorithm identification, comprising: the case configuration module is used for configuring the test case, and setting a reverse proxy address and at least two source station server addresses; The traffic construction module is used for constructing test request traffic and inserting an identification field of a load balancing algorithm into a Header of each test request, wherein the identification field comprises a polling algorithm identification field, a least connection number algorithm identification field and a universal hash algorithm identification field; The algorithm verification module is used for sending a test request carrying a load balancing algorithm identifier to the reverse proxy address, then receiving response flow from the source station server, wherein a Header of the response flow contains the source station identifier of the response source station server, and finally verifying whether the distribution of the request is consistent with a set load balancing algorithm strategy according to the source station identifier in the response flow and the load balancing algorithm identifier in the test request; And the test report module is used for generating a load balancing test report according to the verification result.
- 10. A computer readable storage medium having stored thereon computer executable instructions which when executed by a processor implement a load balancing test method based on algorithmic identification as claimed in any one of claims 1 to 8.
Description
Load balancing test method, system and medium based on algorithm identification Technical Field The present invention relates to the field of network communications technologies, and in particular, to a method, a system, and a medium for load balancing test based on algorithm identification. Background Load balancing techniques are one of the core components in modern network communications by distributing network traffic to multiple servers. With the popularization of virtualization technology and cloud computing, virtualized Web Application Firewalls (WAFs) and their built-in reverse proxy load balancing functions have been widely used in various network architectures. In such an environment, the correctness and stability of the load balancing algorithm are directly related to the service quality and security of the upper layer application. In the prior art, testing for load balancing functions has typically focused on basic functional verification of traffic distribution, such as by modeling client requests and observing the response of each backend server to confirm whether traffic is evenly or as intended distributed. Common testing methods include simulating multi-user concurrent access using a generic stress testing tool, or sending a sequence of requests in a specific pattern through a script, followed by manual inspection of server logs or monitoring metrics to evaluate load balancing effects. However, such existing testing methods have significant limitations. First, they typically only focus on the result of whether traffic is distributed, and lack in depth verification of the process of whether traffic is distributed according to a particular load balancing algorithm. For example, in testing a polling algorithm, existing methods may only count whether the total number of requests received by each server is approximately equal, but cannot strictly verify whether the request sequence is strictly allocated in the polling order. Secondly, for algorithms based on complex strategies such as connection numbers, hash values and the like, the existing test method often depends on manual preset scenes and manual inspection, so that the efficiency is low, and the edge conditions and dynamic change scenes are difficult to cover. Moreover, the existing method is often concerned with only the test result of whether the service flow is loaded or not, and the characteristic that the test result and the used algorithm need to be strongly correlated in the loading process is ignored, so that the traceability and the automatic verification degree of the test result are low. Disclosure of Invention First, the technical problem to be solved In view of the above-mentioned shortcomings and disadvantages of the prior art, the invention provides a load balancing test method, system and medium based on algorithm identification, which solves the technical problems that the existing load balancing test method is difficult to automatically and accurately verify the logic consistency of the load balancing algorithm, and the test process depends on manpower, has low efficiency and has poor traceability. (II) technical scheme In order to achieve the above purpose, the main technical scheme adopted by the invention comprises the following steps: In a first aspect, an embodiment of the present invention provides a load balancing test method based on algorithm identification, including: Configuring a test case, and setting a reverse proxy address and at least two source station server addresses; Constructing test request flow, and inserting an identification field of a load balancing algorithm into a Header of each test request, wherein the identification field comprises a polling algorithm identification field, a least connection number algorithm identification field and a universal hash algorithm identification field; Sending a test request carrying a load balancing algorithm identifier to a reverse proxy address; Receiving response traffic from the source station server, wherein a Header of the response traffic contains a source station identifier of the response source station server; and verifying whether the distribution of the request is consistent with a set load balancing algorithm strategy according to the source station identification in the response flow and the load balancing algorithm identification in the test request, and generating a load balancing test report according to a verification result. Optionally, configuring the test case and setting the reverse proxy address and the at least two source station server addresses includes: Setting a reverse proxy address for designating a load balancing service to be tested and at least two source station servers with different network addresses in a predefined configuration template to obtain a use case configuration data template; According to the test requirement, selecting a current reverse proxy to be tested from a case configuration data template to be combined wit