Layered architecture system for carrying out pressure test on MQTT (Message Queuing Telemetry Transport) protocol and implementation method

Through the layered architecture system and distributed instance coordination mechanism, the problems of high memory usage and large result fluctuations in JMeter stress testing of the MQTT protocol are solved, stable stress testing in high-concurrency scenarios is achieved, and the scalability and consistency of the system are improved.

CN120658662AActive Publication Date: 2025-09-16北京领雁科技股份有限公司
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510992596.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-18
Publication Date
2025-09-16
Estimated Expiration
2045-07-18

AI Technical Summary

Technical Problem

When performing MQTT protocol stress testing, the existing stress testing tool JMeter has problems such as high memory usage and performance consumption due to the large number of threads, and large fluctuations in results caused by uncertainty in CPU scheduling. It also has difficulty meeting the stability requirements in high-concurrency scenarios.

Method used

A layered architecture system is adopted, including the interface layer, business layer, protocol layer and network layer. Through the stress testing thread pool, distributed instance coordination mechanism and configurable I/O framework, stress testing of the MQTT protocol is implemented, reducing the operating system performance overhead and improving concurrency consistency and scalability.

Benefits of technology

It effectively avoids fluctuations in stress testing results due to uncertainty in the operating system's CPU scheduling, reduces system performance overhead, supports stress testing requirements in complex IM business scenarios, and enables configurable scalability and distributed stress testing support in multiple business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120658662A_ABST
    Figure CN120658662A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a layered architecture system for pressure testing of an MQTT protocol and an implementation method, and the layered architecture system comprises an interface layer, a service layer, a protocol layer and a network layer. According to the method and the device, the pressure measurement task is executed by adopting the pressure measurement thread pool, and compared with JMeter which simulates the number of concurrent users through the number of threads, the problem that the pressure measurement result fluctuation of a large number of threads is too large due to the uncertainty of CPU scheduling of an operating system can be effectively avoided, and the performance overhead of the operating system can be effectively reduced. A layered architecture system design concept is adopted, the method can be suitable for a complex IM service scene, a configurable user-defined extension I / O framework can be supported, and through voltage measurement request parameter configuration and I / O framework switching configuration, the voltage measurement requirements under multiple service scenes can be met, and the expandability of the layered architecture system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a layered architecture system and implementation method for performing stress testing on the MQTT protocol. Background Art

[0002] As a lightweight, publish / subscribe messaging protocol, the MQTT (Message Queuing Telemetry Transport) protocol has broad application prospects in the Internet of Things (IoT). High-concurrency and high-frequency interactions between the front-end and back-end are common in IoT applications. Using the MQTT protocol in IoT applications requires stress testing of these service interfaces.

[0003] Existing solutions typically use stress testing tools (such as JMeter) to stress test the MQTT protocol. JMeter utilizes a modular, layered architecture and supports multiple protocols and high-concurrency scenarios. However, using JMeter for stress testing the MQTT protocol has the following drawbacks: Since JMeter does not provide a sampler that supports the MQTT protocol, a custom sampler that supports the MQTT protocol must be implemented and loaded into JMeter for application. During stress testing, a test plan must be created, the number of threads in a thread group defined based on the number of concurrent requesting users must be defined, a custom MQTT sampler configured, and a listener configured to collect stress test results. During this process, since JMeter simulates concurrent requests by defining thread groups, each thread represents a user. A large number of simulated users leads to a corresponding increase in the number of threads created, resulting in increased memory usage on the stress testing device. Furthermore, a larger number of threads also increases the performance consumption of the machine. Furthermore, since thread scheduling is determined by the operating system and is subject to significant uncertainty, some threads may experience starvation, resulting in significant fluctuations in stress test results and failing to meet the non-functional test requirement of less than 10% QPS fluctuation.

[0004] Therefore, a layered architecture system and implementation method for stress testing the MQTT protocol are proposed. Summary of the Invention

[0005] Based on this, it is necessary to provide a layered architecture system and implementation method for stress testing the MQTT protocol to address the above technical issues.

[0006] According to a first aspect of the present invention, a layered architecture system for stress testing the MQTT protocol is provided, including: an interface layer, which is used to provide a calling interface, receive stress testing requests initiated by users and parse stress testing request parameters, encapsulate them into stress testing request configuration objects, initialize functional components and stress testing thread pools; a business layer, which is used to provide business-general functions and corresponding business-general interfaces required for stress testing requests, and start the stress testing thread pool based on a distributed instance coordination mechanism; a protocol layer, which is used to provide sampling operations for MQTT stress testing, encapsulate message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encode it through an I / O framework, and submit it to the stress testing thread pool to asynchronously execute message sending operations, send it to the MQTT server, and receive return messages sent by the MQTT server, decode the receipt information through the I / O framework, encapsulate it into an MQTT message object, call back to the corresponding sampler, and execute corresponding processing logic; a network layer, which is used to send the encoded message body to the MQTT server according to the established network connection, and receive return messages sent by the MQTT server.

[0007] Optionally, the interface layer includes: an interface definition module, which is used to define a calling interface, wherein the calling interface includes a single-chat stress testing interface, a group-chat stress testing interface, and a hybrid stress testing interface; a stress testing request processing module, which is used to receive stress testing requests initiated by users and stress testing request parameters submitted in a form-based manner, and parse the stress testing request parameters using a corresponding parser according to the file type to which the stress testing request parameters belong, and assemble them into a stress testing request configuration object; an initialization module, which is used to initialize functional components and stress testing thread pools.

[0008] Optionally, the functional components include a load generator, a single chat test sampler, a received message sampler and a group chat test sampler.

[0009] Optionally, the business layer includes: a business definition module, used to define the business general functions and corresponding business general interfaces required for stress testing requests; a thread pool startup module, used to start the stress testing thread pool based on a distributed instance coordination mechanism.

[0010] Optionally, the thread pool startup module also includes: a thread coordination module, which is used to start a stress testing thread for stress testing coordination before starting the stress testing thread pool, use Redis's INCR command to perform an atomic increment operation on the shared key, record the current number of stress testing instances, and determine whether the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters. If the current number of stress testing instances does not reach the number of instances configured in the stress testing request parameters, the stress testing thread is blocked by spinning, so that the stress testing thread enters an event-driven waiting state until the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters, triggering event broadcasting, waking up all stress testing threads that have entered the waiting state, entering the stress testing execution phase, and starting the stress testing thread pool.

[0011] Optionally, the business layer also includes: a network connection construction module, which is used to, after the stress testing thread pool is started, each stress testing thread selects an MQTT server from the MQTT service cluster through a polling algorithm, establishes a Socket connection between the stress testing thread and the MQTT server, and stores the established Socket connection in the local cache.

[0012] Optionally, the protocol layer includes: a sampling module, which is used to configure the test type of the object according to the stress testing request, and the stress testing thread calls the corresponding sampler from the functional component, and encapsulates the message data in the stress testing thread into a message body that conforms to the MQTT protocol format through the sampler; an I / O framework implementation module, which is used to provide a configurable I / O framework, encode the encapsulated message body through the I / O framework, and submit it to the stress testing thread pool to asynchronously execute the message sending operation, send it to the corresponding MQTT server, and receive the return message sent by the MQTT server, perform protocol decoding on the receipt information through the I / O framework, and encapsulate it into an MQTT message object, and call back to the corresponding sampler. The sampler executes the corresponding processing logic according to the message type to which the receipt information belongs to obtain the stress testing result.

[0013] Optionally, the I / O framework implementation module also includes: an I / O framework expansion module for providing a newly expanded I / O framework; an I / O framework switching module for dynamically switching the I / O framework and comparing stress test results to select the optimal I / O framework in different business scenarios.

[0014] Optionally, the protocol layer also includes: a thread management module, which is used to enable the corresponding stress testing thread to enter an event-based waiting state after the stress testing thread completes the message sending operation, waiting for the return message to wake up or time out, and updating the success or failure count through an atomic self-increment operation; a performance statistics module, which is used to perform performance statistics on the stress testing results.

[0015] According to the second aspect of the present invention, a method for implementing a layered architecture system for stress testing the MQTT protocol is provided, comprising: providing a calling interface through an interface layer, receiving stress testing requests initiated by users and parsing stress testing request parameters, encapsulating them into stress testing request configuration objects, initializing functional components and stress testing thread pools; providing business-general functions and corresponding business-general interfaces required for stress testing requests through a business layer, and starting a stress testing thread pool based on a distributed instance coordination mechanism; providing a sampling operation for MQTT stress testing through a protocol layer, encapsulating message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encoding it through an I / O framework, and submitting it to the stress testing thread pool for asynchronously executing a message sending operation, sending it to an MQTT server, and receiving a return message sent by the MQTT server, decoding the receipt information through the I / O framework, encapsulating it into an MQTT message object, calling back to the corresponding sampler, and executing corresponding processing logic; sending the encoded message body to the MQTT server through the network layer according to the constructed network connection, and receiving a return message sent by the MQTT server.

[0016] The beneficial effects of the present application are: a layered architecture system and implementation method for stress testing the MQTT protocol provided by the present application have the following beneficial effects: using a stress testing thread pool to execute stress testing tasks, compared to JMeter simulating the number of concurrent users by the number of threads (i.e. one thread corresponds to one user), it can effectively avoid the problem of excessive fluctuations in stress testing results due to the uncertainty of the operating system CPU scheduling caused by a large number of threads, and can effectively reduce the performance overhead of the operating system; adopting a layered architecture system design concept, it can be applicable to complex IM business scenarios, and supports a configurable custom extended I / O framework, through stress testing request parameter configuration and I / O framework switching configuration, it can not only meet the stress testing requirements in multiple business scenarios, but also improve the scalability of the layered architecture system; using Redis's INCR command to perform atomic auto-increment operations on shared keys, it can support distributed stress testing of multiple stress testing instances, and can solve the problem of insufficient performance of JMeter simulating a large number of users concurrently accessing a single machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is an exemplary system architecture diagram to which the present application can be applied.

[0018] Figure 2 This is a structural diagram of an embodiment of a layered architecture system for stress testing the MQTT protocol according to the present application.

[0019] Figure 3 This is a flowchart of an embodiment of a method for implementing a layered architecture system for stress testing the MQTT protocol according to the present application. DETAILED DESCRIPTION

[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0021] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0023] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0024] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0025] Terminal devices 101, 102, and 103 can be various electronic devices with display screens and support web browsing, including but not limited to smartphones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers, desktop computers, etc.

[0026] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0027] It should be noted that the layered architecture system for stress testing the MQTT protocol provided in the embodiment of the present application is generally set in the server / terminal device, and accordingly, the implementation method of the layered architecture system for stress testing the MQTT protocol is generally executed by the server / terminal device.

[0028] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0029] Continue to refer Figure 2 , showing a schematic diagram of the structure of an embodiment of a layered architecture system 200 for stress testing the MQTT protocol according to the present application. The layered architecture system adopts a layered design concept. During the stress testing of the MQTT protocol, each layer only calls the layer below it. This not only facilitates maintenance of the layered architecture system, but also allows for stress testing of the MQTT protocol by only modifying a small amount of code when business scenarios require modification. It also improves the concurrency consistency and scalability of the layered architecture system. The layered architecture system specifically includes: an interface layer 201, a business layer 202, a protocol layer 203, and a network layer 204.

[0030] According to an embodiment of the present application, the interface layer 201 is used to provide a calling interface, receive stress testing requests initiated by users and parse stress testing request parameters, encapsulate them into stress testing request configuration objects, and initialize functional components and stress testing thread pools.

[0031] According to an embodiment of the present application, the interface layer 201 includes: an interface definition module, which is used to define a calling interface, wherein the calling interface includes a single chat stress testing interface, a group chat stress testing interface, and a hybrid stress testing interface; a stress testing request processing module, which is used to receive stress testing requests initiated by users and stress testing request parameters submitted based on a form, and parse the stress testing request parameters using a corresponding parser according to the file type to which the stress testing request parameters belong, and assemble them into a stress testing request configuration object; an initialization module, which is used to initialize functional components and stress testing thread pools.

[0032] It should be noted that "single chat" refers to a one-to-one chat mode, "group chat" refers to a chat mode involving multiple people (3 or more), and "mixed" refers to a stress test mode that conducts both "single chat" and "group chat" simultaneously.

[0033] According to the embodiment of the present application, a single chat stress test scenario is used as an example for explanation. The user can call the layered architecture system provided by the present application by calling the interface and initiate a stress test request. The stress test request parameters are submitted to the layered architecture system in a form. The stress test request parameters for the single chat stress test scenario include but are not limited to: (1) connectUrl: MQTT service connection Url, multiple service instances are separated by English commas, for example: 10.14.122.86:6789, 10.14.122.88:6789; (2) con connectTimeout: MQTT connection timeout; (3) message: sent message content; (4) messageSize: message size, unit b represents bytes, unit k represents kilobytes, unit m represents megabytes. This parameter is not empty. If it is empty, the message is invalid. It should be configured according to actual usage. It should not be too large, preferably not more than 10k (about 5000 characters); (5) needLogin: whether login is required, true: required, false: not required, only for point-to-point testing It is not set to false, and both single chat and group chat are set to true; (6) serviceId: application service ID, obtained through management configuration; (7) appId: application ID, obtained through management configuration; (8) secretKey: message content encryption key; (9) sleepTime: sleep time, adjust the sending rate through the sleep time, optional; (10) testCount: total number of tests; (11) coreSize: number of core threads in the stress test thread pool; (12) maxSize: maximum number of threads in the stress test thread pool; (13) rejectHandler: rejection test of the thread pool, value: abort / discard / discardOldest / callerRuns, default: abort; (14) poolName: stress test thread pool name, optional; (15) blockQueueSize: size of the blocking queue of the sending thread pool; (16) waitResponse: whether to wait for the receipt to be sent, true: yes, false: do not wait.Generally true; (17) waitTime: the timeout for waiting to receive the receipt, in ms; (18) dataFormat: the data format of the user account file, value: cvs / json, generally cvs; (19) userFile: stress test user data file; (20) workerSize: valid when stress testing uses netty, the size of the netty stress test thread pool; (21) instanceCount: the number of instances of the stress test client, the user can coordinate the test with multiple stress test clients; (22) testIdentifier: when there are multiple stress test clients, the unique identifier of this test, different for each test, the current timestamp can be used.

[0034] According to an embodiment of the present application, the interface layer 201 may adopt a test application, such as cmc-test-app, so that the user can call the layered architecture system involved in the present application through the test application. When the interface layer 201 receives the stress test request and stress test request parameters initiated by the user, it will call the corresponding parser according to the file type (such as CSV, JSON) of the stress test request parameters uploaded by the user, extract the stress test request parameters and assemble them into a unified stress test request configuration object, and then initialize the functional components and stress test thread pool.

[0035] According to an embodiment of the present application, the functional components include: a load generator (LoadGenerator) is a component for loading user account and group configuration information, a single chat test sampler (SingleSampler) is used to initiate a single chat stress test and count the number of single chat messages sent, a receiving message sampler (ReceiverSampler) is used to receive single chat, group chat and return messages, and a group chat test sampler (GroupSampler) is used to initiate a group chat stress test and count the number of group chat messages sent.

[0036] According to an embodiment of the present application, the business layer 202 is used to provide the business general functions and corresponding business general interfaces required for stress testing requests, and to start the stress testing thread pool based on a distributed instance coordination mechanism.

[0037] According to an embodiment of the present application, the business layer 202 includes: a business definition module, which is used to define the business general functions and corresponding business general interfaces required for stress testing requests; and a thread pool startup module, which is used to start the stress testing thread pool based on a distributed instance coordination mechanism.

[0038] According to an embodiment of the present application, the thread pool startup module also includes: a thread coordination module, which is used to start a stress testing thread for stress testing coordination before starting the stress testing thread pool, use Redis's INCR command to perform an atomic increment operation on the shared key, record the current number of stress testing instances, and determine whether the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters. If the current number of stress testing instances does not reach the number of instances configured in the stress testing request parameters, the stress testing thread is blocked by spinning, so that the stress testing thread enters an event-driven waiting state until the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters, triggering event broadcasting, waking up all stress testing threads that have entered the waiting state, entering the stress testing execution phase, and starting the stress testing thread pool.

[0039] According to an embodiment of the present application, the business layer 202 also includes: a network connection construction module, which is used to, after the stress testing thread pool is started, each stress testing thread selects an MQTT server from the MQTT service cluster through a polling algorithm, establishes a Socket connection between the stress testing thread and the MQTT server, and stores the established Socket connection in the local cache.

[0040] According to the embodiments of the present application, in order to solve the problems of asynchronous startup of stress test instances and unreliable stress test results in the prior art, the present application adopts a distributed instance coordination mechanism to improve the concurrency consistency of the layered architecture system and the reliability of the stress test results. Specifically, during the stress test startup phase, each instance does not immediately execute the stress test task, but enters a spin-wait state and continuously polls the number of instances recorded in Redis. Only when the current number of stress test instances reaches the number of instances configured in the stress test request parameters, all instances start executing the stress test task almost simultaneously, ensuring the consistency of the stress test concurrent time points and improving the accuracy and comparability of the stress test results. Specific application scenarios include: deploying the layered architecture system to test the MQTT message service capabilities of a large-scale IoT platform. The platform is required to support 100,000 concurrent device connections, each device sends a status message every 5 seconds, and supports point-to-point communication between devices. In order to verify the performance of the platform in high-concurrency scenarios, this layered architecture system is used for distributed stress test verification. For example, the distributed instance coordination mechanism requires starting 10 stress test instances. Assume three stress test instances are already running. The current stress test thread executes INCR and returns a value of 4. Since the total number of instances configured is 10, the stress test thread enters an event-driven wait state to prevent CPU idling. When the 10th instance executes INCR and returns 10, the system determines that the required number of stress test instances has been met, triggers an event broadcast, wakes up all waiting threads, and enters the stress test execution phase. This mechanism ensures the accuracy and consistency of the instance count in a distributed environment through Redis's atomic operations.

[0041] According to an embodiment of the present application, after the stress testing thread pool is started, each stress testing thread selects an MQTT server (node) from the MQTT service cluster using a round-robin algorithm and establishes a socket connection between the two. Upon successful connection, the socket connection is stored in a local cache for reuse in subsequent message transmissions. Based on the configured stress testing request parameters, the system determines whether to perform authentication (e.g., username / password or token) and subscription operations (e.g., subscribing to a single-chat topic) to ensure that the connection is in a communicative state.

[0042] According to an embodiment of the present application, the protocol layer 203 is used to provide a sampling operation for MQTT stress testing, encapsulate the message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encode it through the I / O framework, and submit it to the stress testing thread pool to asynchronously execute the message sending operation, send it to the MQTT server, and receive the return message sent by the MQTT server, decode the receipt information through the I / O framework, and encapsulate it into an MQTT message object, call back to the corresponding sampler, and execute the corresponding processing logic.

[0043] According to an embodiment of the present application, the protocol layer 203 includes: a sampling module, which is used to configure the test type of the object according to the stress test request configuration, and the stress test thread calls the corresponding sampler from the functional component, and encapsulates the message data in the stress test thread into a message body that conforms to the MQTT protocol format through the sampler; an I / O framework implementation module, which is used to provide a configurable I / O framework, encode the encapsulated message body through the I / O framework, and submit it to the stress test thread pool to asynchronously perform a message sending operation, send it to the corresponding MQTT server, and receive the return message sent by the MQTT server, perform protocol decoding on the receipt information through the I / O framework, and encapsulate it into an MQTT message object, and call back to the corresponding sampler. The sampler executes the corresponding processing logic according to the message type to which the receipt information belongs to obtain the stress test result; a thread management module, which is used to enter the event-based waiting state after the stress test thread completes the message sending operation, wait for the return message to wake up or time out, and update the success or failure count through the atomic self-increment operation; a performance statistics module, which is used to perform performance statistics on the stress test results.

[0044] According to an embodiment of the present application, the I / O framework implementation module also includes: an I / O framework expansion module, which is used to provide a newly expanded I / O framework; an I / O framework switching module, which is used to dynamically switch the I / O framework and compare the stress test results to select the optimal I / O framework in different business scenarios.

[0045] According to an embodiment of the present application, during the sampler startup phase, the stress test thread will first call the corresponding sampler (such as SingleSampler) from the functional component based on the test type (such as single chat) to which the stress test request configuration object belongs, wherein the correspondence between the test type and the sampler is specifically as follows: when the test type is single chat, the sampler is SingleSampler; when the test type is group chat, the sampler is GroupSampler; when the test type is mixed, the samplers are SingleSampler and GroupSampler; the sampler encapsulates the message data in the stress test thread into a message body that conforms to the MQTT protocol format (such as authentication messages, subscription messages, Ping messages, PUBLISH messages, etc.), and then encodes the encapsulated message body through the I / O framework and submits it to the stress test thread pool to asynchronously execute the message sending operation and send it to the corresponding MQTT server. In addition, the layered architecture system supports dynamic switching of I / O frameworks so that the optimal I / O framework can be selected in different business scenarios, thereby improving the adaptability and flexibility of the layered architecture system.

[0046] According to the embodiments of the present application, the I / O framework involved in the present application includes but is not limited to the tio framework and the netty framework. Network communication is realized through the tio framework and the netty framework. Among them, the tio framework adopts the AIO asynchronous non-blocking IO method, and the netty framework adopts the NIO synchronous non-blocking IO method. It has excellent performance and can be quickly switched between the tio framework and the netty framework through simple configuration; in addition, it also supports configurable custom extended I / O framework. Only by using the interface of the I / O framework extension module, the newly added extended I / O framework can be implemented to improve the scalability of the layered architecture system.

[0047] According to an embodiment of the present application, after the I / O framework receives the return message sent by the MQTT server, it performs protocol decoding and encapsulates it into a unified MQTT message object, which is then passed to the corresponding sampler through a callback mechanism. The sampler executes the corresponding processing logic based on the message type to which the receipt information belongs. For example, if it is a single chat or group chat message, the sampler's receive count is updated through an atomic self-increment operation; if it is a receipt message (such as PUBACK), the corresponding stress testing thread is awakened through a thread communication mechanism (such as CountDownLatch or CompletableFuture). If the stress testing thread is awakened within the set timeout period, the success count is incremented; if it times out, the failure count is incremented, thereby achieving accurate statistics on the message response delay and success rate.

[0048] According to the embodiments of the present application, the statistical performance includes but is not limited to the total number of sent messages (totalSent), the number of successfully confirmed messages (successAck), the number of failed messages (failed), message sending delay (latencyHistogram), message receiving delay (receiveLatencyHistogram), average response time (Queries Per Second), the failure rate of message sending, etc.

[0049] According to an embodiment of the present application, the network layer 204 is used to send the encoded message body to the MQTT server based on the established network connection, and receive the return message sent by the MQTT server.

[0050] According to embodiments of the present disclosure, any multiple modules of the interface layer 201, service layer 202, protocol layer 203, and network layer 204 can be combined into a single module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module. According to embodiments of the present disclosure, at least one of the interface layer 201, service layer 202, protocol layer 203, and network layer 204 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented in hardware or firmware through any other reasonable means of circuit integration or packaging, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or any appropriate combination of any of these. Alternatively, at least one of the interface layer 201, service layer 202, protocol layer 203, and network layer 204 can be at least partially implemented as a computer program module that, when executed, can perform the corresponding function.

[0051] The electronic device according to an embodiment of the present application includes a processor, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage portion into a random access memory (RAM). The processor may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor may also include onboard memory for caching purposes. The processor may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present application.

[0052] The RAM stores various programs and data required for the operation of the electronic device. The processor, ROM, and RAM are connected to each other via a bus. The processor executes the programs in the ROM and / or RAM to perform the various operations of the method flow according to the embodiments of the present application. It should be noted that the programs may also be stored in one or more memories other than ROM and RAM. The processor may also execute the programs stored in the one or more memories to perform the various operations of the method flow according to the embodiments of the present application.

[0053] According to an embodiment of the present application, the electronic device may further include an input / output (I / O) interface, which is also connected to the bus. The electronic device may further include one or more of the following components connected to the I / O interface: an input portion including a keyboard, a mouse, etc.; an output portion including a cathode ray tube (CRT), a liquid crystal display (LCD), a speaker, etc.; a storage portion including a hard disk, etc.; and a communication portion including a network interface card such as a LAN card or a modem. The communication portion performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as needed. Removable media, such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed in the drive as needed, so that computer programs read therefrom can be installed into the storage portion as needed.

[0054] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of this application is implemented.

[0055] According to embodiments of the present application, a computer-readable storage medium may be a non-volatile computer-readable storage medium, and may include, for example, but not limited to, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present application, a computer-readable storage medium may include the ROM and / or RAM described above, and / or one or more memories other than ROM and RAM.

[0056] The present application also includes a computer program product comprising a computer program containing program code for executing the method shown in the flowchart. When the computer program product is executed in a computer system, the program code is used to cause the computer system to implement the item recommendation method provided in the present application.

[0057] When the computer program is executed by the processor, the above functions defined in the system / device of the embodiment of the present application are performed. According to the embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0058] In one embodiment, the computer program may be stored on a tangible storage medium, such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal over a network medium, downloaded and installed via a communication component, and / or installed from a removable medium. The program code contained in the computer program may be transmitted using any suitable network medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0059] In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion, and / or installed from a removable medium. When the computer program is executed by the processor, the above-mentioned functions defined in the system of the embodiment of the present application are performed. According to the embodiment of the present application, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.

[0060] According to an embodiment of the present application, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).

[0061] Further references Figure 3 , as a response to the above Figure 2The present application provides an embodiment of a method for implementing a layered architecture system for stress testing the MQTT protocol. Figure 2 The system embodiment shown corresponds to the embodiment shown.

[0062] like Figure 3 As shown, the implementation method of a layered architecture system for stress testing the MQTT protocol described in this embodiment includes the following steps.

[0063] S1. Provides a calling interface through the interface layer, receives the stress test request initiated by the user, parses the stress test request parameters, encapsulates them into a stress test request configuration object, and initializes the functional components and stress test thread pool.

[0064] S2. Provide the business-wide functions and corresponding business-wide interfaces required for stress testing requests through the business layer, and start the stress testing thread pool based on the distributed instance coordination mechanism.

[0065] S3. Provide MQTT stress testing sampling operations through the protocol layer, encapsulate the message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encode it through the I / O framework, and submit it to the stress testing thread pool to asynchronously execute the message sending operation, send it to the MQTT server, and receive the return message sent by the MQTT server. Decode the receipt information through the I / O framework, encapsulate it into an MQTT message object, call back to the corresponding sampler, and execute the corresponding processing logic.

[0066] S4. Send the encoded message body to the MQTT server through the network layer according to the established network connection, and receive the return message sent by the MQTT server.

[0067] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0068] The above content is a further detailed description of the present invention in conjunction with specific embodiments, and the specific implementation of the present invention cannot be considered to be limited to these descriptions. For those skilled in the art of the present invention, without departing from the concept of the present invention, several simple deductions or substitutions can be made, which should be considered to fall within the scope of protection of the present invention.

Claims

1. A layered architecture system for stress testing the MQTT protocol, characterized in that: include: The interface layer provides a calling interface, receives user-initiated stress testing requests, parses stress testing request parameters, encapsulates them into stress testing request configuration objects, and initializes functional components and stress testing thread pools. The business layer is used to provide the common business functions and corresponding common business interfaces required for stress testing requests, and to start the stress testing thread pool based on the distributed instance coordination mechanism; The protocol layer is used to provide sampling operations for MQTT stress testing. It encapsulates the message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encodes it through the I / O framework, and submits it to the stress testing thread pool for asynchronous message sending operations. The message is sent to the MQTT server, and the return message sent by the MQTT server is received. The receipt information is decoded through the I / O framework and encapsulated as an MQTT message object. The callback is sent to the corresponding sampler to execute the corresponding processing logic. The network layer is used to send the encoded message body to the MQTT server based on the established network connection, and to receive the return message sent by the MQTT server.

2. A layered architecture system for stress testing the MQTT protocol according to claim 1, characterized in that: The interface layer includes: An interface definition module is used to define a calling interface, wherein the calling interface includes a single chat stress testing interface, a group chat stress testing interface, and a hybrid stress testing interface; The stress test request processing module is used to receive stress test requests initiated by users and stress test request parameters submitted in a form. According to the file type to which the stress test request parameters belong, the corresponding parser is used to parse the stress test request parameters and assemble them into a stress test request configuration object. Initialization module, used to initialize functional components and stress testing thread pool.

3. A layered architecture system for stress testing the MQTT protocol according to claim 2, characterized in that: The functional components include a load generator, a single chat test sampler, a received message sampler and a group chat test sampler.

4. A layered architecture system for stress testing the MQTT protocol according to claim 1, characterized in that: The business layer includes: The business definition module is used to define the common business functions and corresponding common business interfaces required for stress testing requests; The thread pool startup module is used to start the stress testing thread pool based on the distributed instance coordination mechanism.

5. A layered architecture system for stress testing the MQTT protocol according to claim 4, characterized in that: The thread pool startup module also includes: The thread coordination module is used to start a stress testing thread for stress testing coordination before starting the stress testing thread pool, use Redis's INCR command to perform atomic increment operations on shared keys, record the current number of stress testing instances, and determine whether the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters. If the current number of stress testing instances does not reach the number of instances configured in the stress testing request parameters, the stress testing thread is blocked by spinning, and the stress testing thread enters an event-driven waiting state until the current number of stress testing instances reaches the number of instances configured in the stress testing request parameters, triggering event broadcasting, waking up all stress testing threads that have entered the waiting state, entering the stress testing execution phase, and starting the stress testing thread pool.

6. A layered architecture system for stress testing the MQTT protocol according to claim 4, characterized in that: The business layer also includes: The network connection construction module is used to select an MQTT server from the MQTT service cluster through a polling algorithm after the stress testing thread pool is started, establish a Socket connection between the stress testing thread and the MQTT server, and store the established Socket connection in the local cache.

7. A layered architecture system for stress testing the MQTT protocol according to claim 1, characterized in that: The protocol layer includes: The sampling module is used to configure the test type of the object according to the stress test request. The stress test thread calls the corresponding sampler from the functional component, and the sampler encapsulates the message data in the stress test thread into a message body that conforms to the MQTT protocol format. The I / O framework implementation module is used to provide a configurable I / O framework, encode the encapsulated message body through the I / O framework, submit it to the stress testing thread pool to asynchronously execute the message sending operation, send it to the corresponding MQTT server, and receive the return message sent by the MQTT server. The receipt information is decoded by the I / O framework and encapsulated as an MQTT message object, which is called back to the corresponding sampler. The sampler executes the corresponding processing logic according to the message type of the receipt information to obtain the stress testing results.

8. A layered architecture system for stress testing the MQTT protocol according to claim 7, characterized in that: The I / O framework implementation module also includes: I / O framework extension module, used to provide a newly added extended I / O framework; The I / O framework switching module is used to dynamically switch I / O frameworks and compare stress testing results to select the optimal I / O framework in different business scenarios.

9. A layered architecture system for stress testing the MQTT protocol according to claim 7, characterized in that: The protocol layer also includes: The thread management module is used to make the corresponding stress testing thread enter an event-based waiting state after the stress testing thread completes the message sending operation, waiting for the return message to wake up or time out, and update the success or failure count through atomic self-increment operations; The performance statistics module is used to perform performance statistics on stress testing results.

10. A method for implementing a layered architecture system for stress testing the MQTT protocol, characterized in that: include: The interface layer provides a calling interface to receive user-initiated stress testing requests, parse the stress testing request parameters, encapsulate them into stress testing request configuration objects, and initialize functional components and the stress testing thread pool. The business layer provides the common business functions and corresponding common business interfaces required for stress testing requests, and starts the stress testing thread pool based on the distributed instance coordination mechanism. The protocol layer provides MQTT stress testing sampling operations, encapsulates the message data in the stress testing thread into a message body that conforms to the MQTT protocol format, encodes it through the I / O framework, and submits it to the stress testing thread pool for asynchronous message sending operations. The message is sent to the MQTT server, and the return message sent by the MQTT server is received. The receipt information is decoded through the I / O framework and encapsulated as an MQTT message object. The callback is sent to the corresponding sampler to execute the corresponding processing logic. The network layer sends the encoded message body to the MQTT server based on the established network connection, and receives the return message sent by the MQTT server.

Citation Information

Patent Citations

  • Server pressure testing method and device

    CN109491895A

  • High concurrent pressure test method based on flow playback and related device

    CN118250206A

  • Processing method and device for carrying out pressure test on MQTT service interface

    CN118838841A

  • Method and system for testing stability of terminal computing power management platform

    CN119621544A

  • Distributed system high availability test method, device, equipment, storage medium and program product

    CN119718799A