MQTT test method, pressure machine, electronic equipment and storage media
By registering multiple network interface cards (NICs) in the MQTT load testing machine and optimizing port allocation based on the number of idle ports and their weights, the problem of low efficiency when NIC port occupancy is close to saturation is solved, enabling the rapid establishment of MQTT long connections and improving load testing efficiency.
Patent Information
- Application Number
- CN202310449818.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-04-24
AI Technical Summary
During MQTT load testing, when the network interface card (NIC) ports are nearing saturation, expanding the number of connections by adding virtual IPs is inefficient, resulting in long connection establishment times and low load testing efficiency.
By registering multiple network interface cards (NICs) in the MQTT load tester, the number of newly occupied ports in the next collection cycle is determined based on the number of idle ports and weight of each NIC, and the newly added ports are allocated in that cycle to achieve the preset number of test connections. The parallel processing of multiple NICs optimizes port allocation.
It effectively shortens the time from establishing a long MQTT connection to the preset number of connections, improves load testing efficiency, and saves resource costs.
Smart Images

Figure CN118842736B_ABST
Abstract
Description
Technical Field
[0001] This application relates to communication technology, and more particularly to an MQTT stress testing method, a stress tester, an electronic device, and a storage medium. Background Technology
[0002] Currently, the main scenarios for stress testing of Message Queuing Telemetry Transport (MQTT) are: MQTT long connection stress testing, and throughput stress testing for publish and subscribe.
[0003] In MQTT, a persistent connection refers to a connection established between a broker and a client that remains open for a certain period of time. MQTT persistent connection load testing requires establishing a large number of persistent connections between clients and the broker. In practical applications, an MQTT load testing machine can simulate the broker and establish MQTT persistent connections with multiple clients. Each established MQTT persistent connection requires one port on the network interface card (NIC) of the MQTT load testing machine.
[0004] In related technologies, when the number of long connections established by the MQTT load testing machine does not meet the preset number of test connections, and the number of ports occupied by the network card in the MQTT load testing machine is close to saturation, it is necessary to add more virtual IPs to establish more MQTT long connections. This results in a long time for the MQTT load testing machine to establish the preset number of test connections, and the efficiency of MQTT load testing is low. Summary of the Invention
[0005] This application provides an MQTT load testing method, a load tester, an electronic device, and a storage medium, aiming to solve the problem of low efficiency in MQTT load testing.
[0006] Firstly, this application provides an MQTT load testing method applied to an MQTT load testing machine, wherein the MQTT load testing machine is registered with multiple network interface cards (NICs). The method includes: when a collection period arrives, obtaining the number of idle ports for each NIC; determining the number of newly occupied ports for each NIC in the next collection period based on the number of idle ports for each NIC; wherein the number of newly occupied ports for a NIC in the next collection period is the product of the current idle port ratio of the NIC, the weight of the NIC, and a preset target total number of newly occupied ports for all NICs in a single period; the idle port ratio of the NIC is the ratio of the idle port number of the NIC to the sum of the idle ports of all NICs; sending the number of newly occupied ports for the NIC in the next collection period to each NIC, so that the NIC adds a corresponding number of occupied ports in the next collection period according to the number of newly occupied ports, until the sum of the occupied ports of all NICs reaches a preset number of test connections.
[0007] In one possible implementation, after determining the number of newly occupied ports required per unit time for each network card in the next acquisition cycle based on the number of idle ports of each network card, the method further includes: storing the number of newly occupied ports of each network card in the next acquisition cycle to a time-series database in chronological order.
[0008] In one possible implementation, obtaining the number of idle ports for each network interface card (NIC) when a data collection period arrives includes: when a data collection period arrives, obtaining from the time-series database the number of newly occupied ports for each NIC during the current data collection period and during historical data collection periods; calculating the sum of the number of newly occupied ports for each NIC during the current data collection period and during historical data collection periods to obtain the current port occupancy count for each NIC; and calculating the difference between the number of ports for each NIC and the current port occupancy count for each NIC to obtain the current number of idle ports for each NIC.
[0009] In one possible implementation, the plurality of network interface cards (NICs) includes virtual NICs and fixed NICs; before determining the number of newly occupied ports for each NIC in the next collection cycle based on the number of idle ports of each NIC, the method further includes: obtaining the index value of each virtual NIC under each performance metric, and normalizing the index value; wherein, the performance metrics include latency, packet loss rate, transmission rate, and jitter; for each performance metric, calculating the proportion of the index value corresponding to each virtual NIC among the index values corresponding to all virtual NICs; for each performance metric, calculating the entropy value of the performance metric based on the proportion of the index value corresponding to each virtual NIC among the index values corresponding to all virtual NICs; and calculating the difference coefficient of the performance metric based on the entropy value of the performance metric; wherein, the performance index... The difference coefficient of the target represents the degree of difference in the indicator value corresponding to each virtual network interface card (NIC) under the performance indicator. The smaller the difference coefficient of the performance indicator, the greater the difference in the indicator value corresponding to each virtual NIC under the performance indicator. Based on the difference coefficient of the performance indicator, the ratio of the difference parameter of the performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the performance indicator. For each virtual NIC, the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual NIC under the performance indicator to the indicator values of all virtual NICs is calculated. The product results corresponding to all performance indicators are summed to obtain the weight value of the virtual NIC. The sum of the largest weight value among the weight values of all virtual NICs and the configuration parameter is taken as the weight value of the fixed NIC.
[0010] In one possible implementation, the method further includes: installing tunctl in the CentOS environment configured on the MQTT load tester; determining the total number of network cards required for the test based on the preset number of test connections and the number of long connections that each network card can establish; subtracting one from the total number of network cards to obtain the number of virtual network cards to be created; creating the corresponding number of virtual network cards based on the tunctl, configuring IP addresses for the virtual network cards, and adding static routes for the virtual network cards to the routing table to complete the registration of the virtual network cards.
[0011] In one possible implementation, the method further includes: if the number of idle ports of each network card is less than a preset threshold, then registering a virtual network card for the MQTT load tester.
[0012] Secondly, this application provides an MQTT load testing machine, which is registered with multiple network interface cards (NICs). The MQTT load testing machine includes: an acquisition module, used to acquire the number of idle ports of each NIC when a collection period arrives; a management module, used to determine the number of newly occupied ports of each NIC in the next collection period based on the number of idle ports of each NIC; wherein, the number of newly occupied ports of the NIC in the next collection period is the product of the current idle port ratio of the NIC, the weight of the NIC, and the preset target total number of newly occupied ports of all NICs in a single period; the idle port ratio of the NIC is the ratio of the idle port number of the NIC to the sum of the idle ports of all NICs; and an allocation module, used to send the number of newly occupied ports of the NIC in the next collection period to each NIC, so that the NIC adds a corresponding number of occupied ports in the next collection period according to the number of newly occupied ports, until the sum of the occupied ports of all NICs reaches a preset number of test connections.
[0013] In one possible implementation, the MQTT load testing machine further includes a storage module for storing the number of newly occupied ports of each network card in the next acquisition cycle into a time-series database in chronological order.
[0014] In one possible implementation, the acquisition module includes: a reading unit, configured to, when a collection period arrives, acquire from the time-series database the number of newly occupied ports of each network interface card (NIC) within the current collection period and within historical collection periods; a calculation unit, configured to calculate the sum of the number of newly occupied ports of each NIC within the current collection period and within historical collection periods to obtain the current port occupancy count of each NIC; the calculation unit is further configured to calculate the difference between the number of ports of each NIC and the current port occupancy count of each NIC to obtain the current number of free ports of each NIC.
[0015] In one possible implementation, the plurality of network interface cards (NICs) includes virtual NICs and fixed NICs; the MQTT load testing machine further includes a weight determination module; the weight determination module is used to: obtain the index value of each virtual NIC under each performance metric, and normalize the index value; wherein, the performance metrics include latency, packet loss rate, transmission rate, and jitter; for each performance metric, calculate the proportion of the index value corresponding to each virtual NIC among the index values corresponding to all virtual NICs; for each performance metric, calculate the entropy value of the performance metric based on the proportion of the index value corresponding to each virtual NIC among the index values corresponding to all virtual NICs; and calculate the difference coefficient of the performance metric based on the entropy value of the performance metric; wherein, the difference coefficient of the performance metric... The coefficient represents the degree of difference in the indicator value corresponding to each virtual network interface card (NIC) under the performance indicator. The smaller the difference coefficient of the performance indicator, the greater the difference in the indicator value corresponding to each virtual NIC under the performance indicator. Based on the difference coefficient of the performance indicator, the ratio of the difference parameter of the performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the performance indicator. For each virtual NIC, the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual NIC under the performance indicator to the indicator values of all virtual NICs is calculated. The product results corresponding to all performance indicators are summed to obtain the weight value of the virtual NIC. The sum of the largest weight value among all virtual NIC weight values and the configuration parameter is taken as the weight value of the fixed NIC.
[0016] In one possible implementation, the MQTT load testing machine further includes: a first registration module; the first registration module is used to: install tunctl in the CentOS environment configured on the MQTT load testing machine; determine the total number of network cards required for testing based on the preset number of test connections and the number of long connections that each network card can establish; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; create the corresponding number of virtual network cards based on the tunctl, configure IP addresses for the virtual network cards, and add static routes for the virtual network cards to the routing table to complete the registration of the virtual network cards.
[0017] In one possible implementation, the MQTT load tester further includes a second registration module, used to register a virtual network card for the MQTT load tester if the number of idle ports of each network card is less than a preset threshold.
[0018] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method described above.
[0019] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described above.
[0020] In the MQTT stress testing method, stress tester, electronic device, and storage medium provided in this application, when the collection cycle arrives, the number of idle ports of each network card is obtained; based on the number of idle ports of each network card, the weight of the network card, and the preset target total number of newly added ports of all network cards in a single cycle, the number of newly occupied ports of each network card in the next collection cycle is determined; each network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. The proposed solution involves an MQTT load testing machine registered with multiple network interface cards (NICs). The target total number of new ports for all NICs can be set for a single period. The weight of each NIC is related to its actual network performance. The current percentage of idle ports for a NIC represents its relative idleness compared to other NICs. Therefore, based on the current number of idle ports for each NIC, its weight, and the preset target total number of new ports for all NICs in a single period, the number of new occupied ports for each NIC in the next collection period is determined. This effectively ensures that each NIC adds the corresponding number of new occupied ports within a certain timeframe, saving time required to reach the preset number of test connections for established MQTT long connections and improving the efficiency of MQTT load testing. Attached Figure Description
[0021] 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.
[0022] Figure 1 A schematic diagram illustrating a scenario for the MQTT load testing method provided in this application;
[0023] Figure 2 This is a flowchart illustrating an MQTT load testing method provided in Embodiment 1 of this application;
[0024] Figure 3 This is a flowchart illustrating an MQTT load testing method provided in Embodiment 2 of this application;
[0025] Figure 4 This is a flowchart illustrating an MQTT load testing method provided in Embodiment 3 of this application;
[0026] Figure 5 This is a schematic diagram of the structure of an MQTT pressure testing machine provided in Embodiment 4 of this application;
[0027] Figure 6This is a schematic diagram of the structure of the electronic device provided in Embodiment 5 of this application.
[0028] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0030] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0031] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities and do not necessarily imply a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be used interchangeably where appropriate, for example, to implement the application in a sequence other than those given in the embodiments illustrated or described herein.
[0032] Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover but not exclude inclusion. For example, a product or device that includes a series of components is not necessarily limited to those explicitly listed, but may include other components not explicitly listed or inherent to such product or device. As used in this application, the term "module" means any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code capable of performing the functions associated with that element.
[0033] The term "Message Queuing Telemetry Transport Protocol (MQTT)" used in the embodiments of this application refers to a lightweight communication protocol based on a publish-subscribe model, built upon the Transmission Control Protocol (TCP) and Internet Protocol (IP). During communication, MQTT involves three roles: publisher, subscriber, and broker. Publishers and subscribers are both clients, while the broker can be a server, and a publisher can also be a subscriber. Currently, MQTT stress testing scenarios mainly include: MQTT long-connection stress testing, and publish / subscribe throughput stress testing. An MQTT long-connection refers to maintaining a connection between the broker and client for a certain period of time after the connection is established. MQTT long-connection stress testing requires establishing a massive number of long-lived connections between clients and the broker.
[0034] Figure 1 This is a schematic diagram illustrating a scenario for the MQTT load testing method provided in this application. Figure 1 As shown, the MQTT load tester 101 simulates a proxy and establishes MQTT long connections with multiple clients in the system under test 100. Each MQTT long connection requires one port of the network card in the MQTT load tester 101.
[0035] The MQTT load testing machine 101 can be obtained by installing an MQTT plugin on a performance testing tool. For example, the performance testing tool could be JMeter or LoadRunner. In practical applications, the MQTT load testing machine 101 simulates a proxy end, establishing MQTT long connections with multiple clients. Each established MQTT long connection requires one port on the network interface card (NIC) of the MQTT load testing machine.
[0036] In a practical scenario, when the number of MQTT long connections established by the MQTT load testing machine 101 does not meet the preset number of test connections, and the port usage of the network card in the MQTT load testing machine 101 is close to saturation, the number of MQTT long connections that can be established can be expanded by adding a new MQTT load testing machine or by setting a virtual IP on the current MQTT load testing machine 101. Since adding a new MQTT load testing machine will increase the load testing cost, setting a virtual IP can be used to expand the number of long connections that the MQTT load testing machine 101 can establish.
[0037] In practical applications, when the number of network card ports in the MQTT load tester 101 is close to saturation, setting up virtual IPs to establish more MQTT long connections results in a longer time for the MQTT load tester to establish the preset number of long connections, leading to lower efficiency in MQTT load testing.
[0038] In this embodiment, the MQTT load testing machine is registered with multiple network interface cards (NICs). The target total number of new ports for all NICs can be set for a single period. The weight of each NIC is related to its actual network performance. The current percentage of idle ports for a NIC represents its relative idleness compared to other NICs. Therefore, based on the current number of idle ports for each NIC, its weight, and the preset target total number of new ports for all NICs in a single period, the number of new occupied ports for each NIC in the next collection period is determined. This effectively ensures that each NIC adds the corresponding number of new occupied ports within a certain timeframe, saving time in establishing the preset number of test connections for MQTT long connections and improving the efficiency of MQTT load testing.
[0039] The technical solutions of this application will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. In the description of this application, unless otherwise expressly specified and limited, the terms should be broadly understood within the art. The embodiments of this application will now be described with reference to the accompanying drawings.
[0040] Example 1
[0041] Figure 2 This is a flowchart illustrating an MQTT load testing method provided in Embodiment 1 of this application. The method in this embodiment is applied to an MQTT load testing machine, which has multiple network interface cards (NICs) registered, such as... Figure 2 As shown, the method includes the following steps:
[0042] S201. When the collection cycle arrives, obtain the number of idle ports for each network card.
[0043] S202. Based on the number of free ports for each network card, determine the number of newly occupied ports for each network card in the next collection cycle;
[0044] S203. Send the number of newly occupied ports of the above network card in the next collection cycle to each network card, so that the above network card adds the corresponding number of occupied ports in the next collection cycle according to the above number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
[0045] The number of free ports on a network interface card (NIC) refers to the number of ports that are not currently occupied. In practical applications, given a fixed number of new ports to be occupied by the NIC in the next data acquisition cycle, the larger the number of free ports, the shorter the time it takes for the corresponding number of ports to be occupied in the next data acquisition cycle. In other words, the larger the number of free ports, the faster the NIC can add new ports to be occupied.
[0046] In this embodiment, the number of newly occupied ports of the network card in the next acquisition cycle is the product of the current proportion of the network card's idle ports, the weight of the network card, and the preset target total number of newly occupied ports for all network cards in a single cycle. The proportion of the network card's idle ports is the ratio of the number of idle ports of that network card to the sum of the number of idle ports of all network cards.
[0047] The free port percentage of a network interface card (NIC) represents its relative idle level compared to other NICs. A higher free port percentage indicates a higher level of idleness compared to other NICs; conversely, a lower free port percentage indicates a lower level of idleness. In practice, a higher free port percentage means a faster rate at which new ports are added to the NIC compared to other NICs; conversely, a lower free port percentage means a slower rate at which new ports are added to the NIC compared to other NICs. For example, an MQTT load testing machine is registered with network interface cards (NICs) A, B, and C. When the data collection period arrives, the number of idle ports for NIC A is 6000, for NIC B it is 5000, and for NIC C it is 8000. The sum of the number of idle ports for all NICs is 19000. Calculating the ratio of the number of idle ports for each NIC to the sum of the number of idle ports for all NICs, we find that the idle port percentage for NIC A is 6 / 19, for NIC B it is 5 / 19, and for NIC C it is 8 / 19. NIC C has the largest idle port percentage, indicating that NIC C is more idle than NICs A and B.
[0048] Specifically, in step S202, the number of newly occupied ports for each network interface card (NIC) in the next acquisition cycle is determined based on the number of idle ports for each NIC. In one example, for each NIC, the ratio of the number of idle ports of this NIC to the sum of the number of idle ports of all NICs is calculated to obtain the proportion of idle ports of this NIC; the product of the current proportion of idle ports of this NIC, the weight of this NIC, and the preset total number of newly occupied ports of all NICs in a single cycle is calculated to obtain the number of newly occupied ports of this NIC in the next acquisition cycle. For example, the target total number of new ports for all network cards in the next cycle is 190. Network card A has a weight of 1.5, network card B has a weight of 0.8, and network card C has a weight of 0.75. Currently, network card A has 6 / 19 of its free ports, network card B has 5 / 19, and network card C has 8 / 19. The next sampling point is calculated by multiplying the current free port percentage of network card A (6 / 19), the network card weight (1.5), and the preset target total number of new ports for all network cards in a single cycle (190). The number of newly occupied ports for network card A in the current collection period is 90. The product of the current idle port ratio of network card B (5 / 19), the network card weight (0.8), and the preset target total number of newly occupied ports for all network cards in a single period (190) is calculated to obtain the number of newly occupied ports for network card A in the next collection period as 40. The product of the current idle port ratio of network card C (8 / 19), the network card weight (0.75), and the preset target total number of newly occupied ports for all network cards in a single period (190) is calculated to obtain the number of newly occupied ports for network card A in the next collection period as 60.
[0049] Based on the above example, the number of newly occupied ports for a network interface card (NIC) in the next data collection cycle is the product of the current percentage of idle ports for that NIC, the NIC's weight, and the preset target total number of newly occupied ports for all NICs in a single cycle. The NIC's weight is related to its current network performance and remains constant within a single data collection cycle. Furthermore, the target total number of newly occupied ports for all NICs remains constant within the same data collection cycle. Therefore, the number of newly occupied ports for a NIC in the next data collection cycle is positively correlated with the current percentage of idle ports for that NIC; the higher the current percentage of idle ports, the higher the number of newly occupied ports for that NIC in the next data collection cycle.
[0050] It is understandable that when the number of idle ports on a network interface card (NIC) is relatively small, its idle level is lower compared to other NICs, and the rate at which it adds new occupied ports is lower than that of other NICs. This means that the number of new occupied ports that this NIC can add in the next data collection cycle is smaller. Therefore, sending a smaller number of new occupied ports to this NIC in the next data collection cycle ensures that it can efficiently add the corresponding number of new occupied ports in the next data collection cycle. Conversely, when the number of idle ports on a network interface card (NIC) is large, its idle level is higher compared to other NICs, and the rate at which it adds new occupied ports is higher than that of other NICs. This means that the number of new occupied ports that this NIC can add in the next data collection cycle is larger. Therefore, sending a larger number of new occupied ports to this NIC in the next data collection cycle ensures that it can efficiently add the corresponding number of new occupied ports in the next data collection cycle.
[0051] In practical applications, the total number of new ports to be added for all network cards in a single cycle is fixed. When the MQTT load tester registers only a single network card, it takes a long time to add the corresponding number of new ports. When the MQTT load tester registers multiple network cards, the total number of new ports to be added for all network cards can be distributed to multiple network cards for parallel processing, which can save the time of adding ports and improve the efficiency of MQTT load testing.
[0052] In this embodiment, for network interface cards (NICs) with a high percentage of idle ports, the rate at which new ports are added to the network interface card is relatively high compared to other NICs. Sending a larger number of new ports to this NIC in the next acquisition cycle can ensure that the establishment of MQTT long connections is completed within a certain time. Conversely, for NICs with a low percentage of idle ports, the rate at which new ports are added to the network interface card is relatively low compared to other NICs. Sending a smaller number of new ports to this NIC in the next acquisition cycle can ensure that the establishment of MQTT long connections is completed within a certain time. Therefore, this embodiment saves the time required to reach the preset number of test connections for established MQTT long connections, thus improving the efficiency of MQTT load testing.
[0053] It should be noted that during MQTT load testing, the sum of the target number of newly added ports for all network cards across all data collection periods is the preset number of test connections. For different data collection periods, the target number of newly added ports for all network cards in a single period can be the same or different; this is not limited here. For example, for different data collection periods, the target number of newly added ports for all network cards in a single period is set to be the same. Optionally, considering that the number of remaining ports on the network cards decreases over time, the target number of newly added ports for all network cards in a single period can be set to decrease.
[0054] Optionally, in a single period, the target total number of newly added ports for all network cards per unit time can be set. In one example, in S201, when the collection period arrives, the number of idle ports for each network card is obtained. Specifically, this includes: when the collection period arrives, obtaining the number of newly added ports per unit time for each network card; calculating the product of the number of newly occupied ports per unit time for each network card and the duration of the current collection period to obtain the number of newly occupied ports for each network card within the current collection period; for each network card, calculating the sum of the number of newly occupied ports in the current collection period and the number of newly occupied ports in historical collection periods to determine the number of occupied ports for the current network card; and calculating the difference between the total number of ports for the network card and the number of occupied ports for the current network card to obtain the number of idle ports for the current network card.
[0055] Correspondingly, in S202, based on the number of idle ports of each network interface card (NIC), the number of newly occupied ports for each NIC in the next collection cycle is determined. Specifically, this includes: for each NIC, calculating the ratio of the number of idle ports of that NIC to the sum of the number of idle ports of all NICs to obtain the proportion of idle ports of that NIC; calculating the product of the current proportion of idle ports of that NIC, the weight of that NIC, and the preset target total number of newly occupied ports of all NICs per unit time to obtain the number of newly occupied ports of the NIC per unit time in the next cycle; it can be understood that by calculating the product of the number of newly occupied ports of the NIC per unit time in the next cycle and the duration of the next collection cycle, the number of newly occupied ports of the NIC in the next collection cycle can be determined.
[0056] Correspondingly, in S203, the number of newly occupied ports for each network card in the next acquisition cycle is sent to each network card, so that the network cards add a corresponding number of occupied ports in the next acquisition cycle according to the number of newly occupied ports for each network card in the next acquisition cycle, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. Specifically, this includes: sending the number of newly occupied ports of each network card per unit time in the next cycle to each network card, so that the network cards add a corresponding number of occupied ports per unit time in the next acquisition cycle according to the number of newly occupied ports of each network card in the next cycle, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
[0057] Furthermore, in one example, after S202 above, the method further includes:
[0058] The number of newly occupied ports for each network card in the next collection cycle is stored in the time-series database in chronological order.
[0059] A Time Series Database (TSDB) is a database used to store and process time-series data, supporting efficient reading, writing, and computation of this data. Examples of TSDBs include DolphinDB, TimescaleDB, InfluxDB, or TDengine. In practical applications, at the start of each acquisition cycle, the number of idle ports for each network interface card (NIC) is obtained, and based on this number, the number of newly occupied ports for each NIC in the next acquisition cycle is determined. Therefore, the number of newly occupied ports for each NIC in each acquisition cycle is a series of data generated over time.
[0060] For example, the moment when the number of newly occupied ports for each network interface card (NIC) is determined in the next acquisition cycle is used as the timestamp for the number of newly occupied ports for each NIC in the next acquisition cycle, and the number of newly occupied ports for each NIC in the next acquisition cycle is stored in the time-series database in the order of the timestamps. It can be understood that when the acquisition cycle arrives, the time-series database stores the number of newly occupied ports for each NIC in the current acquisition cycle and in the historical acquisition cycles.
[0061] In this example, after determining the number of newly occupied ports for each network card in the next acquisition cycle, the number of newly occupied ports for each network card in the next acquisition cycle is stored in the time series database in chronological order. The time series database makes it easy to obtain the number of newly occupied ports for each network card in the current acquisition cycle and in the historical acquisition cycles.
[0062] Optionally, in one example, the number of newly occupied ports for each network interface card (NIC) in the next data collection cycle is stored in a cache database in chronological order. For example, the cache database could be a remote dictionary server (Redis).
[0063] In practical applications, the total number of ports currently occupied by each network interface card (NIC) can be determined by reading the number of newly occupied ports for each NIC in the current acquisition period and in historical acquisition periods from the time-series database. In one example, S201 includes:
[0064] When the collection period arrives, the number of newly occupied ports of each network card in the current collection period and in the historical collection period is obtained from the time series database.
[0065] Calculate the sum of the number of newly occupied ports for each network card in the current collection period and in the historical collection period to obtain the current port occupancy of each network card;
[0066] Calculate the difference between the number of ports for each network interface card (NIC) and the current number of ports occupied for each NIC to obtain the current number of free ports for each NIC.
[0067] In this example, based on the number of newly occupied ports of each network card in the current acquisition period and the number of ports occupied in the historical acquisition period stored in the time series database, the number of ports occupied by each network card is calculated. Then, by calculating the difference between the number of ports of each network card and the number of ports occupied by each network card, the number of free ports of each network card is obtained.
[0068] Optionally, in one example, after S202 above, the method further includes: storing the number of newly occupied ports of each network card in the next acquisition cycle and the current number of ports occupied by each network card in chronological order into a time-series database.
[0069] Optionally, in one example, S201 above includes:
[0070] When the collection period arrives, the number of newly occupied ports of each network card in the current collection period and the number of ports occupied by each network card in the previous collection period are obtained from the time series database.
[0071] Calculate the number of newly occupied ports for each network card in the current collection period and the sum of the number of ports occupied by each network card in the previous collection period to obtain the current number of ports occupied by each network card.
[0072] Calculate the difference between the number of ports for each network interface card (NIC) and the current number of ports occupied for each NIC to obtain the current number of free ports for each NIC.
[0073] In the MQTT load testing method provided in this embodiment, when the collection period arrives, the number of idle ports of each network card is obtained; based on the number of idle ports of each network card, the weight of the network card, and the preset target total number of newly added ports of all network cards in a single period, the number of newly occupied ports of each network card in the next collection period is determined; each network card adds a corresponding number of occupied ports in the next collection period according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections. In this embodiment of the application, during the MQTT load testing process, the MQTT load testing machine is registered with multiple network cards. The target total number of newly added ports for all network cards in a single period can be set. The weight of the network card is related to the actual network performance of the network card. The current idle port ratio of the network card represents the idle degree of the network card relative to other network cards. Therefore, based on the current idle port number of each network card, the weight of the network card, and the preset target total number of newly added ports for all network cards in a single period, the number of newly occupied ports for each network card in the next collection period is determined. This can effectively ensure that each network card adds the corresponding number of newly occupied ports within a certain period of time, saving the time required to establish the number of MQTT long connections to reach the preset number of test connections, and improving the efficiency of MQTT load testing.
[0074] Example 2
[0075] Figure 3 This is a flowchart illustrating an MQTT stress testing method provided in Embodiment 2 of this application. Multiple network interface cards (NICs) include virtual NICs and fixed NICs; as shown... Figure 3 As shown, based on the above embodiment, before S202, the method further includes:
[0076] S301. Obtain the index value of each virtual network card under each performance index, and normalize the above index values.
[0077] S302. For each performance metric, calculate the proportion of the metric value corresponding to each virtual network interface card (NIC) in the total metric values corresponding to all virtual NICs.
[0078] S303. For each performance metric, calculate the entropy value of the performance metric based on the proportion of the metric value corresponding to each virtual network interface card (NIC) to the metric values corresponding to all virtual NICs; and calculate the difference coefficient of the performance metric based on the entropy value of the performance metric.
[0079] S304. Based on the difference coefficients of the above performance indicators, calculate the ratio of the difference parameters of the above performance indicators to the sum of the difference parameters of all performance indicators, and obtain the weight values of the above performance indicators.
[0080] S305. For each virtual network interface card (NIC), calculate the product of the weight value of each performance indicator and the proportion of the indicator value of the virtual NIC under the above performance indicator in the indicator values of all virtual NICs; sum the above product results for all performance indicators to obtain the weight value of the virtual NIC.
[0081] S306. The sum of the largest weight value among all virtual network interface card weight values and the configuration parameter is used as the weight value of the fixed network interface card mentioned above.
[0082] The performance metrics include latency, packet loss rate, transmission rate, and jitter, which characterize the performance of the network corresponding to the virtual network interface card (NIC). In practical applications, based on the impact of these performance metrics on the network corresponding to the virtual NIC, they can be divided into positive and negative performance metrics. A positive performance metric indicates that the higher the metric value, the better the performance of the network corresponding to the virtual NIC. A negative performance metric indicates that the lower the metric value, the better the performance of the network corresponding to the virtual NIC. For example, transmission rate is a positive performance metric; latency, packet loss rate, and jitter are negative performance metrics. In other examples, more performance metrics may be added or the above performance metrics may be reduced; this application does not specifically limit the performance metrics.
[0083] Specifically, S301 retrieves the metric values for each virtual network interface card (NIC) under each performance metric. For example, the MQTT load testing machine has registered virtual NICs A, B, and C; performance metric 1 is latency, performance metric 2 is packet loss rate, performance metric 3 is transmission rate, and performance metric 4 is jitter. i ' j This represents the value of virtual network card i under the j-th performance metric.
[0084] In practical applications, since performance metrics have varying impacts on the networks corresponding to virtual network interface cards (NICs), normalization can be used. Specifically, S301 normalizes the aforementioned metric values. For example, the normalization formula for positive performance metrics can be expressed as:
[0085]
[0086] The normalization formula for negative performance metrics can be expressed as:
[0087]
[0088] Where n is the number of virtual network interfaces.
[0089] To facilitate understanding, the normalized performance values of each virtual network interface card (NIC) under each performance metric are presented in a table. Table 1 shows the normalized performance values of each virtual NIC under each performance metric. Where X...ij This represents the normalized value of the virtual network interface card i under the j-th performance metric.
[0090] Table 1
[0091] Virtual network adapter Delay (ms) Packet loss rate (%) Transmission speed (Mbps) Jitter (ms) Virtual network card A <![CDATA[x A1 ]]> <![CDATA[x A2 ]]> <![CDATA[x A3 ]]> <![CDATA[x A4 ]]> Virtual network card B <![CDATA[x B1 ]]> <![CDATA[x B2 ]]> <![CDATA[x B3 ]]> <![CDATA[x B4 ]]> Virtual network card C <![CDATA[x C1 ]]> <![CDATA[x C2 ]]> <![CDATA[x C3 ]]> <![CDATA[x C4 ]]>
[0092] In practical applications, for each performance metric, the proportion of the metric value corresponding to each virtual network interface card (NIC) among all the metric values corresponding to all virtual NICs is: the ratio of the metric value of that virtual NIC under that performance metric to the sum of the metric values of all virtual NICs under that performance metric. Referring to Table 1, the metric values in the same column of the table are the metric values corresponding to different virtual NICs under the same performance metric. Therefore, for each performance metric, the proportion of the metric value corresponding to each virtual NIC among all the metric values corresponding to all virtual NICs is: the ratio of the metric value of that virtual NIC under that performance metric to the sum of all the metric values in the corresponding column of that performance metric. For example, under the j-th performance metric, the proportion of the metric value corresponding to virtual NIC i among all the metric values corresponding to all virtual NICs can be expressed as:
[0093]
[0094] Specifically, in S302, for each performance metric, the proportion of the metric value corresponding to each virtual network interface card (NIC) to the total metric values of all virtual NICs is calculated. For example, for performance metric 1 (latency), the metric value x corresponding to virtual NIC A is... A1 The percentage of all virtual network adapters is as follows:
[0095] Optionally, in one example, after S301, an indicator matrix is obtained, where the column vectors of the indicator matrix correspond one-to-one with the performance indicators, and the row vectors correspond one-to-one with the virtual network interfaces (NICs). The column vectors of the indicator matrix include the indicator values of all candidate NICs under the corresponding performance indicator, and the row vectors include the indicator values of the corresponding virtual NIC under all performance indicators. For example, the indicator matrix R can be represented as:
[0096]
[0097] Correspondingly, S302 specifically includes: for each performance metric, calculating the ratio of the metric value corresponding to each virtual network interface card to the sum of all metric values in the column vector corresponding to that performance metric, and obtaining the proportion of the metric value corresponding to each virtual network interface card in the total metric values corresponding to all virtual network interface cards.
[0098] In this embodiment, the difference coefficient of the above performance index represents the degree of difference of the index value corresponding to each virtual network card under the above performance index. The smaller the difference coefficient of the above performance index, the greater the difference of the index value corresponding to each virtual network card under the above performance index.
[0099] Specifically, in S303, for each performance metric, the entropy value of the performance metric is calculated based on the proportion of the metric value corresponding to each virtual network interface card (NIC) to the metric values corresponding to all virtual NICs; and based on the entropy value of the performance metric, the difference coefficient of the performance metric is calculated. For example, the entropy value of the j-th performance metric can be expressed as:
[0100]
[0101] Where k > 0, k = 1 / ln(n), e j ≥0.
[0102] The difference coefficient of the j-th performance indicator can be expressed as:
[0103]
[0104] Where m represents the number of performance indicators.
[0105] Specifically, in S304, based on the difference coefficients of the aforementioned performance indicators, the ratio of the difference parameter of the aforementioned performance indicator to the sum of the difference parameters of all performance indicators is calculated to obtain the weight value of the aforementioned performance indicator. Referring to the example above, the weight value of the j-th performance indicator can be expressed as:
[0106]
[0107] Specifically, in S305, for each virtual network interface card (NIC), the weight value of each performance metric is calculated as the product of the weight value of that virtual NIC and the proportion of the metric value of that virtual NIC among the metric values of all virtual NICs. Referring to the example above, the weight value of the j-th performance metric is w. j The percentage of the performance index value corresponding to virtual network interface card i under the j-th performance index among all the performance index values corresponding to virtual network interface cards is p. ij The product of the weight value of each performance metric and the proportion of the metric value of the aforementioned virtual network interface card (NIC) among the metric values of all virtual NICs is w. j ·p ij .
[0108] Specifically, in S305, the product results of all performance metrics are summed to obtain the weight value of the virtual network interface card (NIC). Referring to the example above, the weight value of virtual NIC i can be expressed as:
[0109]
[0110] In practical applications, due to the performance differences between virtual and fixed network interface cards (NICs), the weight value of the fixed NIC is generally set higher than that of the virtual NIC. Therefore, the sum of the largest weight value among all virtual NICs and the configuration parameters can be used as the weight value of the fixed NIC. The configuration parameters can be pre-set or calculated based on the actual impact of the differences between fixed and virtual NICs on establishing MQTT long connections; no limitation is imposed here.
[0111] In this embodiment, the index value of each virtual network interface card (NIC) under each performance metric is obtained. Based on the index value of each virtual NIC under each performance metric, a series of calculations are performed to obtain the weight value of each virtual NIC. The weight value of the fixed NIC is obtained by summing the weight value with the largest weight value among all virtual NICs and the configuration parameters. The weight values of all NICs are obtained. The weight values of all NICs are related to the network performance of the NIC. Therefore, based on the weight values of all NICs, a more accurate number of newly occupied ports of the NICs in the next collection cycle can be obtained, which can effectively improve the efficiency of MQTT stress testing.
[0112] Optionally, the number of ports for each can be determined, and a corresponding number of virtual network cards can be pre-configured based on a preset number of test connections. In one example, the method further includes:
[0113] Install tunctl in the CentOS environment configured on the aforementioned MQTT load testing machine;
[0114] Based on the preset number of test connections and the number of long connections that each network card can establish, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created;
[0115] Based on the above tunctl, create the corresponding number of virtual network interfaces, configure IP addresses for the virtual network interfaces, and add static routes for the virtual network interfaces to the routing table to complete the registration of the virtual network interfaces.
[0116] In this example, tunctl is a command-line tool for operating virtual network interfaces. In practice, the MQTT load testing machine is configured with a CentOS environment. Installing tunctl in the CentOS environment allows for the registration of virtual network interfaces. Optionally, check if tunctl is installed in the CentOS environment configured on the MQTT load testing machine. If tunctl is installed, directly create the corresponding number of virtual network interfaces based on tunctl.
[0117] The number of persistent connections a network interface card (NIC) can establish is equal to the maximum number of ports that the NIC can be used for. The number of persistent connections a NIC can establish cannot exceed the number of ports it can use. In practical applications, if the current number of ports occupied by the NIC is less than the number of persistent connections it can establish, then those ports can continue to be used to establish MQTT persistent connections; if the current number of ports occupied by the NIC is greater than the number of persistent connections it can establish, then those ports cannot continue to be used to establish MQTT persistent connections.
[0118] It's understandable that the number of long connections each network interface card (NIC) can establish can be the same or different, and the total number of long connections for each NIC equals the preset number of test connections. For example, if each NIC can establish the same number of long connections, the ratio of the preset number of test connections to the number of long connections each NIC can establish determines the total number of NICs required for the test. It should be noted that the MQTT load tester has fixed NICs registered on it; for example, the fixed NIC could be eth0 (fiber optic Ethernet interface card). Therefore, after determining the total number of NICs required for the test, subtract one from the total number of NICs to obtain the number of virtual NICs to be created.
[0119] In practical applications, after creating the corresponding number of virtual network interfaces (NICs), configure IP addresses for each NIC and add static routes for them to the routing table. The virtual NICs added to the routing table can then communicate with the MQTT client. It's important to note that it's not necessary to configure IP addresses for the fixed NICs. Instead, when adding static routes for the virtual NICs to the routing table, you can also add static routes for the fixed NICs to the routing table. The fixed NICs added to the routing table can then communicate with the MQTT client.
[0120] Specifically, based on the aforementioned tunctl, a corresponding number of virtual network interfaces are created, IP addresses are configured for each virtual network interface, and static routes for each virtual network interface are added to the routing table to complete the registration of the virtual network interfaces. For example, if the number of virtual network interfaces to be created is 3, virtual network interfaces tap1, tap2, and tap3 are created using tunctl; Class C IP addresses are configured for virtual network interfaces tap1, tap2, and tap3 using tunctl; and static routes for virtual network interfaces tap1, tap2, and tap3 are added to the routing table to complete the registration of virtual network interfaces tap1, tap2, and tap3.
[0121] In practice, virtual network adapters can also be created using other virtual network adapter command-line tools. For example, the iptuntap tool can be used to create the corresponding number of network adapters. Optionally, other virtual network adapter command-line tools can be combined with tunctl in this example to create virtual network adapters; this is not a limitation.
[0122] In this example, the number of virtual network interfaces to be created is determined based on the preset number of test connections and the number of long connections that each network interface can establish. The creation and registration of the corresponding number of virtual network interfaces are completed using tunctl. By creating the corresponding number of virtual network interfaces, it is possible to effectively avoid creating new virtual network interfaces when the port usage of the current network interface is close to saturation, thereby improving the efficiency of MQTT load testing.
[0123] Optionally, if the number of free ports for each network interface card (NIC) is less than a preset threshold, no new ports will be allocated to that NIC in the next data collection cycle. In one example, the method further includes:
[0124] If the number of idle ports for each network card is less than the preset threshold, then a virtual network card will be registered for the MQTT load tester.
[0125] In practical applications, to ensure the rate at which each network card establishes long connections, if the number of idle ports of a network card is less than a preset threshold, no new ports will be allocated to that network card in the next cycle. New ports will be allocated to network cards whose number of idle ports is not less than the preset threshold. Therefore, when the number of idle ports of each network card is less than the preset threshold, and the number of ports occupied by all network cards has not reached the preset number of test connections, a virtual network card can be registered for the above-mentioned MQTT load testing machine.
[0126] Referring to the above example, the number of long connections that each network interface card (NIC) can establish is the difference between the number of ports on that NIC and a preset threshold. In the example above, based on the preset number of test connections and the number of long connections that each NIC can establish, the total number of NICs required for the test is determined. Subtracting one from the total number of NICs yields the number of virtual NICs to be created. In practice, ports on NICs may become unavailable or fail to establish long connections but remain occupied. When the number of free ports on all NICs is less than the preset threshold, the current port occupancy of all NICs has not reached the preset number of test connections. Virtual NICs can be registered for the MQTT load testing machine until the number of long connections established by the MQTT load testing machine reaches the preset number of test connections, thereby achieving unbroken long connections and no abnormal load testing results.
[0127] In this example, if the number of idle ports of each network card is less than the preset threshold, a virtual network card is registered for the MQTT load tester. This can effectively ensure that the number of long connections established by the MQTT load tester reaches the preset number of test connections, ensuring that there are no broken long connections, no abnormal load test results, and improving the reliability of MQTT.
[0128] In the MQTT load testing method provided in this application, the indicator value of each virtual network interface card (NIC) under each performance metric is obtained. Based on the indicator value of each virtual NIC under each performance metric, the weight value of each virtual NIC and the weight value of the fixed NIC are calculated. In the scheme of this application embodiment, the weight value of all NICs is related to the network performance of that NIC. Therefore, based on the weight values of all NICs, a more accurate number of newly occupied ports of the NICs in the next collection cycle can be obtained, which can effectively improve the efficiency of MQTT load testing.
[0129] Example 3
[0130] To facilitate understanding of the solution, the following will provide an exemplary description of Embodiment 3 of this application, in which the MQTT load testing machine is registered with 3 virtual network cards and one fixed network card. Figure 4 This is a flowchart illustrating an MQTT load testing method provided in Embodiment 3 of this application, as shown below. Figure 4 As shown, the MQTT load testing method of Embodiment 3 of this application includes the following steps:
[0131] Step 1: When the collection period arrives, the acquisition module obtains the number of idle ports for each network card.
[0132] Step 2: The weight determination module determines the weight value for each network interface card (NIC).
[0133] Step 3: The management module determines the number of newly occupied ports for each network interface card (NIC) in the next collection cycle based on the number of idle ports for each NIC. The number of newly occupied ports for a NIC in the next collection cycle is the product of the current percentage of idle ports for that NIC, the weight of that NIC, and the preset target total number of newly occupied ports for all NICs in a single cycle. The percentage of idle ports for a NIC is the ratio of the number of idle ports for that NIC to the sum of the number of idle ports for all NICs.
[0134] Step 4: The storage module stores the number of newly occupied ports of each network card in the next acquisition cycle into the time series database in chronological order.
[0135] Step 5: The allocation module retrieves the number of newly occupied ports for each network card in the next acquisition cycle from the time series database, and sends the number of newly occupied ports for the network card in the next acquisition cycle to each network card.
[0136] Step 6: For each network card, add the corresponding number of occupied ports in the next collection cycle according to the corresponding number of newly occupied ports;
[0137] Step 7: If the sum of the number of ports occupied by all network cards does not reach the preset number of test connections, then proceed to step 1; if the sum of the number of ports occupied by all network cards reaches the preset number of test connections, then end the MQTT stress test.
[0138] In the MQTT load testing method provided in this embodiment, when the collection period arrives, the acquisition module obtains the number of idle ports for each network interface card (NIC); the weight determination module determines the weight value for each NIC; the management module determines the number of newly occupied ports for each NIC in the next collection period based on the number of idle ports for each NIC; the storage module stores the number of newly occupied ports for each NIC in the next collection period into the time-series database in chronological order; the allocation module obtains the number of newly occupied ports for each NIC in the next collection period from the time-series database and sends the number of newly occupied ports for each NIC in the next collection period to each NIC; each NIC adds a corresponding number of occupied ports in the next collection period according to the corresponding number of newly occupied ports; until the sum of the number of occupied ports for all NICs reaches the preset number of test connections. In this embodiment of the application, during the MQTT load testing process, the MQTT load testing machine is registered with multiple network cards. The target total number of newly added ports for all network cards in a single period can be set. The weight of the network card is related to the actual network performance of the network card. The current idle port ratio of the network card represents the idle degree of the network card relative to other network cards. Therefore, based on the current idle port number of each network card, the weight of the network card, and the preset target total number of newly added ports for all network cards in a single period, the number of newly occupied ports for each network card in the next collection period is determined. This can effectively ensure that each network card adds the corresponding number of newly occupied ports within a certain period of time, saving the time required to reach the preset number of test connections for the number of established MQTT long connections, and improving the efficiency of MQTT load testing.
[0139] Example 4
[0140] Figure 5 This is a schematic diagram of the structure of an MQTT load testing machine provided in Embodiment 4 of this application. The MQTT load testing machine is registered with multiple network cards, such as... Figure 5 As shown, the MQTT pressure testing machine includes:
[0141] The acquisition module 51 is used to acquire the number of idle ports of each network card when the acquisition period arrives;
[0142] The management module 52 is used to determine the number of newly occupied ports for each network card in the next collection cycle based on the number of idle ports for each network card. The number of newly occupied ports for each network card in the next collection cycle is the product of the current proportion of idle ports for that network card, the weight of that network card, and the preset target total number of newly occupied ports for all network cards in a single cycle. The proportion of idle ports for a network card is the ratio of the number of idle ports for that network card to the sum of the number of idle ports for all network cards.
[0143] The allocation module 53 is used to send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
[0144] The number of free ports on a network interface card (NIC) refers to the number of ports that are not currently occupied. In practical applications, given a fixed number of new ports to be occupied by the NIC in the next data acquisition cycle, the larger the number of free ports, the shorter the time it takes for the corresponding number of ports to be occupied in the next data acquisition cycle. In other words, the larger the number of free ports, the faster the NIC can add new ports to be occupied.
[0145] The free port percentage of a network interface card (NIC) represents its relative idle level compared to other NICs. A higher free port percentage indicates a higher level of idleness compared to other NICs; conversely, a lower free port percentage indicates a lower level of idleness. In practice, a higher free port percentage means a faster rate at which new ports are added to the NIC compared to other NICs; conversely, a lower free port percentage means a slower rate at which new ports are added to the NIC compared to other NICs.
[0146] In one example, the management module 52 is specifically used to: for each network interface card (NIC), calculate the ratio of the number of idle ports of the NIC to the sum of the number of idle ports of all NICs to obtain the proportion of idle ports of the NIC; calculate the product of the current proportion of idle ports of the NIC, the weight of the NIC, and the total number of target new ports of all NICs in a preset single period to obtain the number of newly occupied ports of the NIC in the next collection period.
[0147] Based on the above example, the number of newly occupied ports for a network interface card (NIC) in the next data collection cycle is the product of the current percentage of idle ports for that NIC, the NIC's weight, and the preset target total number of newly occupied ports for all NICs in a single cycle. The NIC's weight is related to its current network performance and remains constant within a single data collection cycle. Furthermore, the target total number of newly occupied ports for all NICs remains constant within the same data collection cycle. Therefore, the number of newly occupied ports for a NIC in the next data collection cycle is positively correlated with the current percentage of idle ports for that NIC; the higher the current percentage of idle ports, the higher the number of newly occupied ports for that NIC in the next data collection cycle.
[0148] It is understandable that when the number of idle ports on a network interface card (NIC) is relatively small, its idle level is lower compared to other NICs, and the rate at which it adds new occupied ports is lower than that of other NICs. This means that the number of new occupied ports that this NIC can add in the next data collection cycle is smaller. Therefore, sending a smaller number of new occupied ports to this NIC in the next data collection cycle ensures that it can efficiently add the corresponding number of new occupied ports in the next data collection cycle. Conversely, when the number of idle ports on a network interface card (NIC) is large, its idle level is higher compared to other NICs, and the rate at which it adds new occupied ports is higher than that of other NICs. This means that the number of new occupied ports that this NIC can add in the next data collection cycle is larger. Therefore, sending a larger number of new occupied ports to this NIC in the next data collection cycle ensures that it can efficiently add the corresponding number of new occupied ports in the next data collection cycle.
[0149] In practical applications, the total number of new ports to be added for all network cards in a single cycle is fixed. When the MQTT load tester only registers a single network card, it takes a long time to add the corresponding number of new ports. When the MQTT load tester registers multiple network cards, the total number of new ports to be added for all network cards can be distributed to multiple network cards for parallel processing, which can save the time of adding ports and improve the efficiency of MQTT load testing.
[0150] In this embodiment, for network interface cards (NICs) with a high percentage of idle ports, the rate at which new ports are added to the network interface card is relatively high compared to other NICs. Sending a larger number of new ports to this NIC in the next acquisition cycle can ensure that the establishment of MQTT long connections is completed within a certain time. Conversely, for NICs with a low percentage of idle ports, the rate at which new ports are added to the network interface card is relatively low compared to other NICs. Sending a smaller number of new ports to this NIC in the next acquisition cycle can ensure that the establishment of MQTT long connections is completed within a certain time. Therefore, this embodiment saves the time required to reach the preset number of test connections for established MQTT long connections, thus improving the efficiency of MQTT load testing.
[0151] It should be noted that during MQTT load testing, the sum of the target number of newly added ports for all network cards across all data collection periods is the preset number of test connections. For different data collection periods, the target number of newly added ports for all network cards in a single period can be the same or different; this is not limited here. For example, for different data collection periods, the target number of newly added ports for all network cards in a single period is set to be the same. Optionally, considering that the number of remaining ports on the network cards decreases over time, the target number of newly added ports for all network cards in a single period can be set to decrease.
[0152] Optionally, in a single period, the target total number of newly added ports for all network cards can be set per unit time. In one example, the acquisition module 51 is specifically used to: when the collection period arrives, acquire the number of newly added ports per unit time for each network card, calculate the product of the number of newly occupied ports per unit time for each network card and the duration of the current collection period, and acquire the number of newly occupied ports for each network card in the current collection period; for each network card, calculate the sum of the number of newly occupied ports in the current collection period and the number of newly occupied ports in the historical collection periods to determine the number of occupied ports for the current network card; calculate the difference between the total number of ports for the network card and the number of occupied ports for the current network card to obtain the number of free ports for the current network card.
[0153] Correspondingly, the management module 52 is specifically used for: for each network interface card (NIC), calculating the ratio of the number of idle ports of the NIC to the sum of the number of idle ports of all NICs, to obtain the proportion of idle ports of the NIC; calculating the product of the current proportion of idle ports of the NIC, the weight of the NIC, and the preset target total number of newly added ports of all NICs per unit time, to obtain the number of newly occupied ports of the NIC per unit time in the next cycle; it can be understood that by calculating the product of the number of newly occupied ports of the NIC per unit time in the next cycle and the duration of the next collection cycle, the number of newly occupied ports of the NIC in the next collection cycle can be determined.
[0154] Correspondingly, the allocation module 53 is specifically used to: send the number of newly occupied ports of the network card in the next cycle per unit time to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle per unit time according to the number of newly occupied ports of the network card in the next cycle per unit time, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
[0155] In one possible implementation, the MQTT pressure testing machine further includes:
[0156] The storage module is used to store the number of newly occupied ports of each network card in the next acquisition cycle into the time-series database in chronological order.
[0157] Time-series databases are used to store and process time-series data, supporting efficient reading, writing, and computation of this data. Examples of time-series databases include DolphinDB, TimescaleDB, InfluxDB, or TDengine. In practical applications, at the start of each acquisition cycle, the number of idle ports for each network interface card (NIC) is obtained, and based on this number, the number of newly occupied ports for each NIC in the next acquisition cycle is determined. Therefore, the number of newly occupied ports for each NIC in each acquisition cycle is a series of data generated over time.
[0158] For example, the moment when the number of newly occupied ports for each network interface card (NIC) is determined in the next acquisition cycle is used as the timestamp for the number of newly occupied ports for each NIC in the next acquisition cycle, and the number of newly occupied ports for each NIC in the next acquisition cycle is stored in the time-series database in the order of the timestamps. It can be understood that when the acquisition cycle arrives, the time-series database stores the number of newly occupied ports for each NIC in the current acquisition cycle and in the historical acquisition cycles.
[0159] In this example, after determining the number of newly occupied ports for each network card in the next acquisition cycle, the number of newly occupied ports for each network card in the next acquisition cycle is stored in the time series database in chronological order. The time series database makes it easy to obtain the number of newly occupied ports for each network card in the current acquisition cycle and in the historical acquisition cycles.
[0160] Optionally, in one example, the number of newly occupied ports for each network interface card (NIC) in the next acquisition cycle is stored in a cache database in chronological order. For example, the cache database could be a remote dictionary service.
[0161] In practical applications, the total number of ports currently occupied by a network interface card (NIC) can be determined by reading the number of newly occupied ports for each NIC in the current acquisition period and in historical acquisition periods from the time-series database. In one example, the acquisition module 51 includes:
[0162] The reading unit is used to retrieve the number of newly occupied ports of each network card in the current collection period and in the historical collection periods from the time series database when the collection period arrives.
[0163] The calculation unit is used to calculate the sum of the number of newly occupied ports of each network card in the current collection period and in the historical collection period, so as to obtain the current port occupancy of each network card.
[0164] The aforementioned calculation unit is also used to calculate the difference between the number of ports of each network card and the current number of ports occupied by each network card, so as to obtain the number of free ports of each network card at present.
[0165] In this example, based on the number of newly occupied ports of each network card in the current acquisition period and the number of ports occupied in the historical acquisition period stored in the time series database, the number of ports occupied by each network card is calculated. Then, by calculating the difference between the number of ports of each network card and the number of ports occupied by each network card, the number of free ports of each network card is obtained.
[0166] Optionally, in one example, the storage module is further configured to store the number of newly occupied ports and the current number of ports occupied by each network card in the next acquisition cycle into a time-series database in chronological order.
[0167] Optionally, in one example, the acquisition module is further configured to: when the acquisition period arrives, retrieve from the time series database the number of newly occupied ports of each network card in the current acquisition period and the number of ports occupied by each network card in the previous acquisition period; calculate the sum of the number of newly occupied ports of each network card in the current acquisition period and the number of ports occupied by each network card in the previous acquisition period to obtain the current number of ports occupied by each network card; and calculate the difference between the number of ports of each network card and the current number of ports occupied by each network card to obtain the current number of free ports of each network card.
[0168] In one possible implementation, the MQTT pressure testing machine further includes: a weight determination module; the weight determination module is used for:
[0169] Obtain the metric value of each virtual network interface card under each performance metric, and normalize the above metric values;
[0170] For each performance metric, calculate the percentage of the metric value corresponding to each virtual network interface card (NIC) in the total metric values corresponding to all virtual NICs.
[0171] For each performance metric, the entropy value of the performance metric is calculated based on the proportion of the metric value corresponding to each virtual network interface card (NIC) to the metric values corresponding to all virtual NICs; and the difference coefficient of the performance metric is calculated based on the entropy value of the performance metric.
[0172] Based on the difference coefficients of the above performance indicators, the ratio of the difference parameters of the above performance indicators to the sum of the difference parameters of all performance indicators is calculated to obtain the weight values of the above performance indicators.
[0173] For each virtual network interface card (NIC), calculate the product of the weight value of each performance metric and the proportion of the metric value of the virtual NIC under the above performance metric among the metric values of all virtual NICs; sum the above product results for all performance metrics to obtain the weight value of the virtual NIC.
[0174] The sum of the largest weight value among all virtual network interface cards (NICs) and the configuration parameter is used as the weight value of the aforementioned fixed NIC.
[0175] The performance metrics include latency, packet loss rate, transmission rate, and jitter, which characterize the performance of the network corresponding to the virtual network interface card (NIC). In practical applications, based on the impact of these performance metrics on the network corresponding to the virtual NIC, they can be divided into positive and negative performance metrics. A positive performance metric indicates that the higher the metric value, the better the performance of the network corresponding to the virtual NIC. A negative performance metric indicates that the lower the metric value, the better the performance of the network corresponding to the virtual NIC. For example, transmission rate is a positive performance metric; latency, packet loss rate, and jitter are negative performance metrics. In other examples, more performance metrics may be added or the above performance metrics may be reduced; this application does not specifically limit the performance metrics.
[0176] In practical applications, for each performance metric, the percentage of the metric value corresponding to each virtual network interface card (NIC) among the metric values corresponding to all virtual NICs is: the ratio of the metric value of the virtual NIC under that performance metric to the sum of the metric values of all virtual NICs under that performance metric.
[0177] Optionally, in one example, the index value of each virtual network interface card (NIC) under each performance metric is obtained, and after normalizing these index values, an index matrix is obtained. In the index matrix, the column vectors correspond one-to-one with the performance metrics, and the row vectors correspond one-to-one with the virtual NICs. The column vectors of the index matrix include the index values of all candidate NICs under the corresponding performance metric, and the row vectors include the index values of the corresponding virtual NIC under all performance metrics. Correspondingly, for each performance metric, the ratio of the index value corresponding to each virtual NIC to the sum of all index values in the column vector corresponding to that performance metric is calculated to obtain the proportion of the index value corresponding to each virtual NIC among the index values corresponding to all virtual NICs.
[0178] In this embodiment, the difference coefficient of the above performance index represents the degree of difference of the index value corresponding to each virtual network card under the above performance index. The smaller the difference coefficient of the above performance index, the greater the difference of the index value corresponding to each virtual network card under the above performance index.
[0179] In practical applications, due to the performance differences between virtual and fixed network interface cards (NICs), the weight value of the fixed NIC is generally set higher than that of the virtual NIC. Therefore, the sum of the largest weight value among all virtual NICs and the configuration parameters can be used as the weight value of the fixed NIC. The configuration parameters can be pre-set or calculated based on the actual impact of the differences between fixed and virtual NICs on establishing MQTT long connections; no limitation is imposed here.
[0180] In this embodiment, the index value of each virtual network interface card (NIC) under each performance metric is obtained. Based on the index value of each virtual NIC under each performance metric, a series of calculations are performed to obtain the weight value of each virtual NIC. The weight value of the fixed NIC is obtained by summing the weight value with the largest weight value among all virtual NICs and the configuration parameters. The weight values of all NICs are obtained. The weight values of all NICs are related to the network performance of the NIC. Therefore, based on the weight values of all NICs, a more accurate number of newly occupied ports of the NICs in the next collection cycle can be obtained, which can effectively improve the efficiency of MQTT stress testing.
[0181] Furthermore, in one example, the aforementioned MQTT load testing machine further includes: a first registration module; the first registration module is used for:
[0182] Install tunctl in the CentOS environment configured on the aforementioned MQTT load testing machine;
[0183] Based on the preset number of test connections and the number of long connections that each network card can establish, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created;
[0184] Based on the above tunctl, create the corresponding number of virtual network interfaces, configure IP addresses for the virtual network interfaces, and add static routes for the virtual network interfaces to the routing table to complete the registration of the virtual network interfaces.
[0185] In this example, tunctl is a command-line tool for operating virtual network interfaces. In practice, the MQTT load testing machine is configured with a CentOS environment. Installing tunctl in the CentOS environment allows for the registration of virtual network interfaces. Optionally, check if tunctl is installed in the CentOS environment configured on the MQTT load testing machine. If tunctl is installed, directly create the corresponding number of virtual network interfaces based on tunctl.
[0186] The number of persistent connections a network interface card (NIC) can establish is equal to the maximum number of ports that the NIC can be used for. The number of persistent connections a NIC can establish cannot exceed the number of ports it can use. In practical applications, if the current number of ports occupied by the NIC is less than the number of persistent connections it can establish, then those ports can continue to be used to establish MQTT persistent connections; if the current number of ports occupied by the NIC is greater than the number of persistent connections it can establish, then those ports cannot continue to be used to establish MQTT persistent connections.
[0187] It's understandable that the number of long connections each network interface card (NIC) can establish can be the same or different, and the total number of long connections for each NIC equals the preset number of test connections. For example, if each NIC can establish the same number of long connections, the ratio of the preset number of test connections to the number of long connections each NIC can establish determines the total number of NICs required for the test. It should be noted that the MQTT load tester has fixed NICs registered on it; for example, the fixed NIC could be eth0 (fiber optic Ethernet interface card). Therefore, after determining the total number of NICs required for the test, subtract one from the total number of NICs to obtain the number of virtual NICs to be created.
[0188] In practical applications, after creating the corresponding number of virtual network interfaces (NICs), configure IP addresses for each NIC and add static routes for them to the routing table. The virtual NICs added to the routing table can then communicate with the MQTT client. It's important to note that it's not necessary to configure IP addresses for the fixed NICs. Instead, when adding static routes for the virtual NICs to the routing table, you can also add static routes for the fixed NICs to the routing table. The fixed NICs added to the routing table can then communicate with the MQTT client.
[0189] In practice, virtual network adapters can also be created using other virtual network adapter command-line tools. For example, the iptuntap tool can be used to create the corresponding number of network adapters. Optionally, other virtual network adapter command-line tools can be combined with tunctl in this example to create virtual network adapters; this is not a limitation.
[0190] In this example, the number of virtual network interfaces to be created is determined based on the preset number of test connections and the number of long connections that each network interface can establish. The creation and registration of the corresponding number of virtual network interfaces are completed using tunctl. By creating the corresponding number of virtual network interfaces, it is possible to effectively avoid creating new virtual network interfaces when the port usage of the current network interface is close to saturation, thereby improving the efficiency of MQTT load testing.
[0191] Optionally, if the number of idle ports for each network interface card (NIC) is less than a preset threshold, no new ports will be allocated to that NIC in the next data collection cycle. In one example, the aforementioned MQTT load testing machine further includes: a second registration module; the second registration module is used for:
[0192] If the number of idle ports for each network card is less than the preset threshold, then a virtual network card will be registered for the MQTT load tester.
[0193] In practical applications, to ensure the rate at which each network card establishes long connections, if the number of idle ports of a network card is less than a preset threshold, no new ports will be allocated to that network card in the next cycle. New ports will be allocated to network cards whose number of idle ports is not less than the preset threshold. Therefore, when the number of idle ports of each network card is less than the preset threshold, and the number of ports occupied by all network cards has not reached the preset number of test connections, a virtual network card can be registered for the above-mentioned MQTT load testing machine.
[0194] Referring to the above example, the number of long connections that each network interface card (NIC) can establish is the difference between the number of ports on that NIC and a preset threshold. In the example above, based on the preset number of test connections and the number of long connections that each NIC can establish, the total number of NICs required for the test is determined. Subtracting one from the total number of NICs yields the number of virtual NICs to be created. In practice, ports on NICs may become unavailable or fail to establish long connections but remain occupied. When the number of free ports on all NICs is less than the preset threshold, the current port occupancy of all NICs has not reached the preset number of test connections. Virtual NICs can be registered for the MQTT load testing machine until the number of long connections established by the MQTT load testing machine reaches the preset number of test connections, thereby achieving unbroken long connections and no abnormal load testing results.
[0195] In this example, if the number of idle ports of each network card is less than the preset threshold, a virtual network card is registered for the MQTT load tester. This can effectively ensure that the number of long connections established by the MQTT load tester reaches the preset number of test connections, ensuring that there are no broken long connections, no abnormal load test results, and improving the reliability of MQTT.
[0196] In the MQTT load testing machine provided in this embodiment, the acquisition module acquires the number of idle ports for each network interface card (NIC) when the acquisition period arrives; the management module determines the number of newly occupied ports for each NIC in the next acquisition period based on the number of idle ports for each NIC, the weight of the NIC, and the preset target total number of newly added ports for all NICs in a single period; the allocation module sends the number of newly occupied ports for each NIC in the next acquisition period to each NIC, so that the NIC adds a corresponding number of occupied ports in the next acquisition period according to the number of newly occupied ports, until the sum of the number of occupied ports of all NICs reaches the preset number of test connections. In this embodiment of the application, during the MQTT load testing process, the MQTT load testing machine is registered with multiple network cards. The target total number of newly added ports for all network cards in a single period can be set. The weight of each network card is related to its actual network performance. The current percentage of idle ports for a network card represents its relative idleness compared to other network cards. Therefore, based on the current number of idle ports for each network card, its weight, and the preset target total number of newly added ports for all network cards in a single period, the number of newly occupied ports for each network card in the next collection period is determined. This effectively ensures that each network card adds the corresponding number of newly occupied ports within a certain time, saving time in establishing the preset number of test connections for MQTT long connections and improving the efficiency of MQTT load testing.
[0197] Example 5
[0198] Figure 6 This is a schematic diagram of the structure of the electronic device provided in Embodiment 5 of this application, as shown below. Figure 6 As shown, the electronic device includes:
[0199] The processor 61 and main control device also include a memory 62; it may also include a communication interface 63 and a bus 64. The processor 61, memory 62, and communication interface 63 can communicate with each other via the bus 64. The communication interface 63 can be used for information transmission. The processor 61 can call logical instructions in the memory 62 to execute the methods of the above embodiments.
[0200] Furthermore, the logical instructions in the aforementioned memory 62 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
[0201] The memory 62, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this application. The processor 61 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 62, thereby implementing the methods in the above-described method embodiments.
[0202] The memory 62 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 62 may include high-speed random access memory and may also include non-volatile memory.
[0203] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method in any of the embodiments. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0204] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0205] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. An MQTT load testing method, characterized in that, Applied to an MQTT load testing machine, wherein the MQTT load testing machine is registered with multiple network interface cards, the method includes: When the data collection period arrives, obtain the number of available ports for each network interface card. Based on the number of free ports for each network interface card (NIC), determine the number of newly occupied ports for each NIC in the next data collection cycle; wherein, the number of newly occupied ports for a NIC in the next data collection cycle is the product of the current percentage of free ports for that NIC, the weight of that NIC, and the preset target total number of newly occupied ports for all NICs in a single cycle; the percentage of free ports for a NIC is the ratio of the number of free ports for that NIC to the sum of the number of free ports for all NICs; Send the number of newly occupied ports of each network card in the next collection cycle, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
2. The method according to claim 1, characterized in that, After determining the number of newly occupied ports required per unit time for each network interface card (NIC) in the next data collection cycle based on the number of idle ports for each NIC, the method further includes: The number of newly occupied ports for each network card in the next collection cycle is stored in the time-series database in chronological order.
3. The method according to claim 2, characterized in that, When the collection period arrives, the number of idle ports for each network interface card is obtained, including: When the collection period arrives, the number of newly occupied ports of each network card in the current collection period and in the historical collection period is obtained from the time series database; Calculate the sum of the number of newly occupied ports for each network interface card (NIC) during the current acquisition period and during the historical acquisition periods to obtain the current port occupancy number for each NIC; Calculate the difference between the number of ports for each network interface card (NIC) and the current number of ports occupied for each NIC to obtain the current number of free ports for each NIC.
4. The method according to claim 1, characterized in that, The multiple network interface cards (NICs) include virtual NICs and fixed NICs; before determining the number of newly occupied ports for each NIC in the next acquisition cycle based on the number of free ports for each NIC, the method further includes: Obtain the metric value of each virtual network interface card under each performance metric, and normalize the metric value; wherein, the performance metric includes latency, packet loss rate, transmission rate, and jitter; For each performance metric, calculate the percentage of the metric value corresponding to each virtual network interface card (NIC) in the total metric values corresponding to all virtual NICs. For each performance metric, the entropy value of the performance metric is calculated based on the proportion of the metric value corresponding to each virtual network interface card (NIC) among the metric values corresponding to all virtual NICs. Then, based on the entropy value of the performance metric, the difference coefficient of the performance metric is calculated. The difference coefficient of the performance metric represents the degree of difference of the metric value corresponding to each virtual NIC under the performance metric. The smaller the difference coefficient of the performance metric, the greater the difference of the metric value corresponding to each virtual NIC under the performance metric. Based on the difference coefficient of the performance index, the ratio of the difference parameter of the performance index to the sum of the difference parameters of all performance indices is calculated to obtain the weight value of the performance index. For each virtual network interface card (NIC), calculate the product of the weight value of each performance metric and the proportion of the metric value of the virtual NIC under the performance metric among the metric values of all virtual NICs; sum the product results corresponding to all performance metrics to obtain the weight value of the virtual NIC. The sum of the largest weight value among all virtual network interface card (NIC) weight values and the configuration parameter is used as the weight value of the fixed NIC.
5. The method according to claim 4, characterized in that, The method further includes: Install tunctl in the CentOS environment configured on the MQTT load tester; Based on the preset number of test connections and the number of long connections that each network card can establish, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; Based on the tunctl, a corresponding number of virtual network interfaces are created, IP addresses are configured for the virtual network interfaces, and static routes for the virtual network interfaces are added to the routing table to complete the registration of the virtual network interfaces.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: If the number of idle ports for each network card is less than a preset threshold, then a virtual network card is registered for the MQTT load tester.
7. An MQTT pressure testing machine, characterized in that, The MQTT load testing machine is registered with multiple network interface cards (NICs), and the MQTT load testing machine includes: The acquisition module is used to obtain the number of idle ports for each network card when the collection period arrives; The management module is used to determine the number of newly occupied ports for each network interface card (NIC) in the next data collection cycle based on the number of idle ports for each NIC. The number of newly occupied ports for a NIC in the next data collection cycle is the product of the current percentage of idle ports for that NIC, the weight of that NIC, and the preset target total number of newly occupied ports for all NICs in a single cycle. The percentage of idle ports for a NIC is the ratio of the number of idle ports for that NIC to the sum of the number of idle ports for all NICs. The allocation module is used to send the number of newly occupied ports of the network card in the next collection cycle to each network card, so that the network card adds a corresponding number of occupied ports in the next collection cycle according to the number of newly occupied ports, until the sum of the number of occupied ports of all network cards reaches the preset number of test connections.
8. The MQTT pressure testing machine according to claim 7, characterized in that, The MQTT pressure testing machine also includes: The storage module is used to store the number of newly occupied ports of each network card in the next acquisition cycle into the time-series database in chronological order.
9. The MQTT pressure testing machine according to claim 8, characterized in that, The acquisition module includes: The reading unit is used to obtain the number of newly occupied ports of each network card in the current collection period and in the historical collection period from the time series database when the collection period arrives. The calculation unit is used to calculate the sum of the number of newly occupied ports of each network card in the current collection period and in the historical collection period, so as to obtain the current port occupancy of each network card; The calculation unit is also used to calculate the difference between the number of ports of each network card and the current number of ports occupied by each network card, so as to obtain the number of free ports of each network card.
10. The MQTT pressure testing machine according to claim 7, characterized in that, The plurality of network interface cards (NICs) includes virtual NICs and fixed NICs; the MQTT stress tester further includes a weight determination module; the weight determination module is used for: Obtain the metric value of each virtual network interface card under each performance metric, and normalize the metric value; wherein, the performance metric includes latency, packet loss rate, transmission rate, and jitter; For each performance metric, calculate the percentage of the metric value corresponding to each virtual network interface card (NIC) in the total metric values corresponding to all virtual NICs. For each performance metric, the entropy value of the performance metric is calculated based on the proportion of the metric value corresponding to each virtual network interface card (NIC) among the metric values corresponding to all virtual NICs. Then, based on the entropy value of the performance metric, the difference coefficient of the performance metric is calculated. The difference coefficient of the performance metric represents the degree of difference of the metric value corresponding to each virtual NIC under the performance metric. The smaller the difference coefficient of the performance metric, the greater the difference of the metric value corresponding to each virtual NIC under the performance metric. Based on the difference coefficient of the performance index, the ratio of the difference parameter of the performance index to the sum of the difference parameters of all performance indices is calculated to obtain the weight value of the performance index. For each virtual network interface card (NIC), calculate the product of the weight value of each performance metric and the proportion of the metric value of the virtual NIC under the performance metric among the metric values of all virtual NICs; sum the product results corresponding to all performance metrics to obtain the weight value of the virtual NIC. The sum of the largest weight value among all virtual network interface card (NIC) weight values and the configuration parameter is used as the weight value of the fixed NIC.
11. The MQTT pressure testing machine according to claim 10, characterized in that, The MQTT pressure testing machine further includes: a first registration module; the first registration module is used for: Install tunctl in the CentOS environment configured on the MQTT load tester; Based on the preset number of test connections and the number of long connections that each network card can establish, determine the total number of network cards required for the test; subtract one from the total number of network cards to obtain the number of virtual network cards to be created; Based on the tunctl, a corresponding number of virtual network interfaces are created, IP addresses are configured for the virtual network interfaces, and static routes for the virtual network interfaces are added to the routing table to complete the registration of the virtual network interfaces.
12. The MQTT pressure testing machine according to any one of claims 7-11, characterized in that, The MQTT pressure testing machine also includes: The second registration module is used to register a virtual network card for the MQTT load tester if the number of idle ports of each network card is less than a preset threshold.
13. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-6.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Message caching method and device
CN109617832A
Pressure testing method, device and system
CN111294250A