Disclosure of Invention
The technical scheme provided by the invention is as follows:
the invention provides a method for testing long connection capacity, which comprises the following steps: s10, the client reads the configuration file on the virtual server, the configuration file includes the number of the service servers, the IP of each service server and a plurality of monitoring ports; s20, the client initiates a long connection request to the monitoring port of the service server through the virtual server according to the configuration file; s30, detecting the performance consumption parameters of the virtual server and the service server in real time according to the long connection established between the client and the service server; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate; and S40, when the performance consumption parameters of the virtual server and/or the service server reach the preset performance consumption parameters, the client stops initiating the long connection request, and records the number of the long connections established between the client and the service server.
Further, the method also comprises the following steps: s41, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, replacing the monitoring port in the step S20, and then jumping to execute the step S20; or after replacing the client terminal in the step S10 and the service server in the step S20, the process skips to execute the step S10.
Further, the step S20 further includes: and S21, the multiple connection ports of the client sequentially initiate multiple long connection requests to one monitoring port of the service server through the virtual server respectively according to the configuration file.
Further, the step S41 further includes: s411, when the performance consumption parameters of the virtual server and/or the service server reach preset performance consumption parameters, checking whether all monitoring ports of the service server establish long connection with the connection port of the client; s412, when a long connection is established between a part of the monitoring ports of the service server and the connection port of the client, replacing the monitoring port in the step S21 with an unconnected monitoring port in the service server, and then jumping to perform the step S21; s413, when all monitoring ports of the service server establish long connections with the connection port of the client, replacing the client in the step S10 with another client, and after replacing the service server in the step S20 with another service server, jumping to execute step S10.
Further, before the step S10, the method further includes: s01, building a topology framework among a plurality of clients, a virtual server and a plurality of service servers, and a network environment of the topology framework; and a plurality of service servers in the topology framework form a service server cluster and then are connected to the virtual server.
Further, before the step S10, the method further includes: s03, respectively configuring a running environment mode of a long connection service program on the service server, wherein the testing environment mode comprises a production environment mode and a testing environment mode; the production environment mode is as follows: configuring a monitoring port on the business server to run a long connection service program; the test environment mode is as follows: and configuring a plurality of monitoring ports on the business server to run a long connection service program.
Further, before the step S10, the method further includes: s02, configuring at least 4 service servers in the configuration file on the virtual server, and configuring the IP and multiple monitoring ports of each service server, where the number of the monitoring ports of the service server is less than the number of the connection ports on the client.
The invention also provides a test system with long connection capacity, which comprises a client, a virtual server and a service server, wherein the client comprises: the reading module is used for reading configuration files on the virtual servers, wherein the configuration files comprise the number of the service servers, the IP of each service server and a plurality of monitoring ports; the connection port is used for initiating a long connection request to the monitoring port of the service server through the virtual server according to the configuration file; the detection module is used for detecting the performance consumption parameters of the virtual server and the service server in real time according to the long connection established between the client and the service server; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate; the system comprises a connection control module and a recording module, wherein when the performance consumption parameters of the virtual server and/or the service server reach preset performance consumption parameters, the connection control module is used for controlling to stop initiating long connection requests, and the recording module is used for recording the number of the established long connections between the client and the service server.
Further, the client further comprises: the replacing module is used for replacing the monitoring port when the performance consumption parameter of the virtual server and/or the service server reaches a preset performance consumption parameter; or replacing the client and the service server.
Further, the plurality of connection ports of the client sequentially initiate a plurality of long connection requests to one monitoring port of the service server through the virtual server respectively according to the configuration file.
Compared with the prior art, the test method and the test system for the long connection capacity have the following beneficial effects:
1) after the IP and the monitoring ports of the service server and the service server are configured, the client initiates a long connection request to the service server through the virtual server, the service server responds to the long connection request and establishes long connection with the client, and then performance consumption parameters of the virtual server and the service server are detected in real time. And when the performance consumption parameters of the virtual server and/or the service server reach the preset performance consumption parameters, stopping initiating the long connection request, and recording the number of the established long connections. The invention uses the simplest and lowest cost method to obtain the long connection quantity of the system under the condition of setting the hardware index and ensuring the stable operation of the system.
2) Under the condition of test simulation, one client can initiate tens of thousands of long connections to one monitoring port of one service server through the virtual server, one client can initiate millions of long connections to a plurality of monitoring ports of one service server through the virtual server, and a plurality of clients can initiate tens of millions of long connections to a plurality of service servers through the virtual server. The invention completes the test of tens of millions of long connections by using a simple and low-cost system.
3) The test environment mode is suitable for testing the long connection number in the research and development stage and the product test stage; the production environment mode is suitable for determining the number of long connections applied to the actual application process of the product. The performance overhead is the same for both a port and multiple ports during operation. Therefore, the maximum number of long connections that can be supported under the determined hardware index of the service server in the production environment mode can be accurately evaluated through the test environment mode.
4) The number of monitoring ports on the configuration service server is far less than that of the connecting ports on the client, so that the test of tens of millions of long connections is realized; rather than configuring the number of monitoring ports on the traffic server to be greater than or equal to the number of connection ports on the client. The method is not only used for simplifying the configuration operation steps of configuring the monitoring ports in the configuration file, but also used for enabling the client to quickly read the monitoring ports configured in the configuration file.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
As shown in fig. 1, according to an embodiment of the present invention, a method for testing a long connection capacity includes the following steps: s10, the client reads the configuration file on the virtual server, the configuration file includes the number of the service servers, the IP of each service server and a plurality of monitoring ports;
s20, the client initiates a long connection request to the monitoring port of the service server through the virtual server according to the configuration file;
s30, detecting the performance consumption parameters of the virtual server and the service server in real time according to the long connection established between the client and the service server; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate;
s40, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, the client stops initiating the long connection request, and records the number of the long connections established between the client and the service server;
preferably, the method further comprises the following steps: s41, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, replacing the monitoring port in the step S20, and then jumping to execute the step S20; or after replacing the client terminal in the step S10 and the service server in the step S20, the process skips to execute the step S10.
Specifically, L VS is an abbreviation of L inux Virtual Server, that is, the IP load balancing technology of L inux Virtual Server, L VS is implemented by an IPVS module (IP Virtual Server). IPVS is the core of L VS cluster system, installed on a Director Server (dispatcher), and at the same time, an IP address is virtually simulated on the Director Server (dispatcher). a client must access a service Server through the Virtual IP address.
Socket, commonly referred to as a "Socket," describes an IP address and port, and is a handle of a communication chain that can be used to implement communication between different virtual servers or different computers. A plurality of service software is generally run on the Internet host to provide a plurality of services. Each service opens a Socket and binds to a port, with different ports corresponding to different services.
As shown in fig. 2, according to another embodiment of the present invention, a method for testing a long connection capacity includes the steps of: s01, building a topological framework among a plurality of (for example, 4) clients, a virtual server and a plurality of (for example, 4) servers, and establishing a network environment of the topological framework; and a plurality of service servers in the topology framework form a service server cluster and then are connected to the virtual server.
S02, configuring at least 4 service servers in the configuration file on the virtual server, and configuring the IP and a plurality of monitoring ports of each service server.
S03, respectively configuring a running environment mode of a long connection service program on the service server, wherein the testing environment mode comprises a production environment mode and a testing environment mode; the production environment mode is as follows: configuring a monitoring port on the business server to run a long connection service program; the test environment mode is as follows: and configuring a plurality of monitoring ports on the business server to run a long connection service program.
S10, the client reads the configuration file on the virtual server, the configuration file includes the number of the service servers, the IP of each service server and a plurality of monitoring ports;
and S21, the multiple connection ports of the client sequentially initiate multiple long connection requests to one monitoring port of the service server through the virtual server respectively according to the configuration file.
S30, detecting the performance consumption parameters of the virtual server and the service server in real time according to the long connection established between the client and the service server; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate;
s40, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, the client stops initiating the long connection request, and records the number of the long connections established between the client and the service server;
preferably, the method further comprises the following steps: s41, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, replacing the monitoring port in the step S20, and then jumping to execute the step S20; or after replacing the client terminal in the step S10 and the service server in the step S20, the process skips to execute the step S10.
Specifically, the test environment mode is suitable for being applied to a research and development stage or a condition of testing a product after the research and development are completed, and the production environment mode is suitable for being applied to an application environment after the product is completed. The performance overhead is the same for long connection service programs running on one port and running on multiple ports. Therefore, the maximum number of long connections that can be supported under the determined hardware index of the service server in the production environment mode can be accurately evaluated through the test environment mode. 4 service servers can be configured on the virtual server, and 5, 6 and other service servers can also be configured on the virtual server; each service server has 6 ten thousand ports, and 50, 60 and other ports are selected as monitoring ports from the 6 ten thousand ports. Each client has 64511 ports and can initiate 64511 connections (eliminating 1024 system reserved ports). Taking 60000 connections initiated by each client as an example, 50 monitoring ports are configured on each service server, each client can initiate 300 ten thousand long connections to 4 service servers, and 4 clients can simulate 1200 ten thousand long connections to 4 service servers. For example, when testing services between a large number of intelligent devices (e.g., more than 3000 ten thousand) and the cloud server system, it may be difficult to obtain a true more than 3000 ten thousand intelligent devices for performing service testing.
As shown in fig. 3, according to still another embodiment of the present invention, a method for testing a long connection capacity includes the steps of: s01, building a topological framework among a plurality of (for example, 4) clients, a virtual server and a plurality of (for example, 4) servers, and establishing a network environment of the topological framework; and a plurality of service servers in the topology framework form a service server cluster and then are connected to the virtual server.
S02, configuring at least 4 service servers in the configuration file on the virtual server, and configuring the IP and a plurality of monitoring ports of each service server.
S03, respectively configuring a running environment mode of a long connection service program on the service server, wherein the testing environment mode comprises a production environment mode and a testing environment mode; the production environment mode is as follows: configuring a monitoring port on the business server to run a long connection service program; the test environment mode is as follows: and configuring a plurality of monitoring ports on the business server to run a long connection service program.
S10, the client reads the configuration file on the virtual server, the configuration file includes the number of the service servers, the IP of each service server and a plurality of monitoring ports;
and S21, the multiple connection ports of the client sequentially initiate multiple long connection requests to one monitoring port of the service server through the virtual server respectively according to the configuration file.
S30, detecting the performance consumption parameters of the virtual server and the service server in real time according to the long connection established between the client and the service server; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate;
s40, when the performance consumption parameter of the virtual server and/or the service server reaches the preset performance consumption parameter, the client stops initiating the long connection request, and records the number of the long connections established between the client and the service server;
s411, when the performance consumption parameters of the virtual server and/or the service server reach preset performance consumption parameters, checking whether all monitoring ports of the service server establish long connection with the connection port of the client;
s412, when a long connection is established between a part of the monitoring ports of the service server and the connection port of the client, replacing the monitoring port in the step S21 with an unconnected monitoring port in the service server, and then jumping to perform the step S21;
s413, when all monitoring ports of the service server establish long connections with the connection port of the client, replacing the client in the step S10 with another client, and after replacing the service server in the step S20 with another service server, jumping to execute step S10.
Specifically, 6 ten thousand long connection requests are sequentially initiated to the virtual server by 6 ten thousand connection ports of one client for the first time, and after a load scheduler on the virtual server selects one service server according to the load condition of the service server, one monitoring port of the service server sequentially responds to the 6 ten thousand long connection requests initiated by the client. After long connection is established with the client in sequence, performance consumption parameters (CPU utilization rate and memory occupancy rate) of the virtual server and the service server are detected in real time.
And when the CPU utilization rate and the memory occupancy rate of the virtual server reach 80 percent and/or the CPU utilization rate and the memory occupancy rate of the service server reach 80 percent, the client stops initiating the long connection request and records the number of the established long connections between the client and the service server. And when the CPU utilization rate and the memory occupancy rate of the virtual server do not reach 80 percent and/or the CPU utilization rate and the memory occupancy rate of the business server do not reach 80 percent, checking whether all monitoring ports of the business server are connected with the connection port of the client in a long way or not.
And when the long connection is established between part of the monitoring ports of the service server and the connection ports of the client, replacing the connection ports with the other unconnected monitoring ports, and repeating the steps. And after long connection is established between all monitoring ports of the service server and the connection port of the client, the service server is replaced by another client and another service server, and the steps are repeated.
As shown in fig. 4, according to an embodiment of the present invention, a test system with a long connection capacity includes a plurality of clients 10, a virtual server 20, and a plurality of service servers 30: building a topology framework among a plurality of (for example, 4) clients 10, one virtual server 20, a plurality of (for example, 4) service servers 30, and a network environment of the topology framework; a plurality of service servers 30 in the topology framework form a service server cluster and then are connected to the virtual server 20.
The service server 30 includes a mode configuration module 31, configured to configure an operation environment mode of the long connection service program on the service server 30, where the test environment mode includes a production environment mode and a test environment mode; the production environment mode is as follows: configuring a monitoring port on the service server 30 to run a long connection service program; the test environment mode is as follows: a plurality of monitoring ports are configured on the service server 30 to run a long connection service program.
The virtual server 20 includes a file configuration module 21, configured to configure at least 4 service servers 30 in a configuration file on the virtual server 20, and configure an IP and a plurality of monitoring ports of each service server 30.
Each client 10 includes: a reading module 11, configured to read a configuration file on the virtual server 20, where the configuration file includes the number of the service servers 30, the IP of each service server 30, and multiple monitoring ports;
the connection ports 12 of the client 10 respectively initiate a plurality of long connection requests to a monitoring port of the service server 30 through the virtual server 20 according to the configuration file.
The detection module 13 is configured to detect performance consumption parameters of the virtual server 20 and the service server 30 in real time according to the long connection established between the client 10 and the service server 30; the performance consumption parameters comprise CPU utilization rate and memory occupancy rate;
a connection control module 14 and a recording module 15, where when the performance consumption parameter of the virtual server 20 and/or the service server 30 reaches a preset performance consumption parameter, the connection control module 14 is configured to control to stop initiating a long connection request, and the recording module 15 is configured to record the number of long connections established between the client 10 and the service server 30;
the checking module 16 is configured to check whether all monitoring ports of the service server 30 establish a long connection with the connection port 12 of the client 10 when the performance consumption parameter of the virtual server 20 and/or the service server 30 reaches a preset performance consumption parameter;
a replacing module 17, configured to, when a long connection is established between a part of the monitoring ports of the service server 30 and the connection port 12 of the client 10, replace the monitoring port with an unconnected monitoring port in the service server 30, and then repeat the above steps;
a replacing module 17, configured to replace the client 10 with another client 10 when all monitoring ports of the service server 30 establish long connections with the connection port 12 of the client 10, and repeat the above steps after replacing the service server 30 with another service server 30.
Specifically, the detection module 13 may be disposed on the client 10, or may be disposed on the virtual server 20 and the service server 30, respectively. The viewing module 16 may be provided on the client terminal 10 or on the service server 30. The replacement module 17 may be provided on the client terminal 10 or on the virtual server 20.
As shown in fig. 5 and 6, according to still another embodiment of the present invention, a method for testing long connection capacity includes the steps of building a network environment based on a three-layer topology architecture of a client, L inux virtual servers L VS and long connection service servers, wherein a cluster of the long connection service servers is connected to L inux virtual servers L VS, L inux virtual servers L VS, the theoretical maximum value is the maximum and the number of connections is in the order of ten million.
In the configuration file of the L inux virtual server L VS, the IP and port of the long connection service server that needs to be forwarded are configured, 4 server IPs are configured, and each server IP configures forwarding of 50 ports.
The method comprises the steps that a long connection service program runs on 4 long connection service servers, the long connection service program has a production environment mode and a test environment mode which are distinguished and can be configured through a configuration file, if the long connection service program is in the production environment mode, the long connection service program runs on a designated port on the long connection service server, if the long connection service program is in the test environment mode, the long connection service program can automatically read L content in the configuration file of the VS server and run and record performance expenses (CPU utilization rate and memory occupancy rate) of the long connection service program according to a plurality of configured ports on the long connection service server.
If the long-connection service server is opened with 50 monitoring ports, the port of one client can initiate 64511 connections (removing 1024 system reserved ports), taking 60000 connections initiated by each client as an example, 50 monitoring ports are opened on the long-connection service server, each client can initiate 300 ten thousand long connections, 4 clients can simulate 1200 ten thousand long connections, the client simulator establishes a long connection in such a way that one monitoring port is started every minute, before the monitoring port is started to establish a long connection next time, the performance consumption conditions of the L inux virtual server 56 VS and the long-connection service server are detected in real time, the cumulative consumption of the CPU is less than 80%, and the total consumption of the CPU is recorded when the CPU is started, and when the CPU is started, the total consumption of the CPU is less than 80%.
The maximum long connection number which can be supported by L inux virtual server L VS (set hardware index) and long connection service server (set hardware index) can be determined by the method, taking 4 servers and 50 ports as examples, the maximum long connection number can be determined in time after the hardware index of the long connection service server is changed, elastic expansion and contraction are achieved, server resources are reasonably used according to the number of intelligent terminals, and the method can dynamically expand the number of the servers and the ports to support the test of the number of the more massive (hundreds of millions of levels) long connections.
The invention establishes a long connection service server system cluster and simulates a program of a long connection client to determine the long connection capacity of each layer (L inux virtual server L VS, long connection service server) in a system network component so as to correctly evaluate the number of intelligent terminal hardware supported by the system and the hardware resources of the corresponding system server.
The invention can determine the number of long connections with mass (ten million scale) with less computing resources (4 client servers). The client simulation program and the long connection service program automatically configure a dynamic starting port to operate according to the L inux virtual server L VS.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.