The use of JMeter MQTT in connection test scenarios

Through the previous articles, I believe that you are already familiar with the basic knowledge of JMeter and the use of MQTT plug-ins. From the beginning of this article, we use these test tools to test the actual combat. This article will cover testing of MQTT connections.

Connection Scenario Analysis

The MQTT Connect request in the plug-in mainly simulates the establishment of a connection between the device and the MQTT server (this article takes EMQX as an example), and sends MQTT keep alive packets at specified intervals. In actual IoT scenarios, a large number of devices are often connected and kept online. Online and offline; the script in this article will simulate 400 devices to establish a connection with EMQX at the same time, and keep the connection for 30 minutes and then offline at the same time.

How to write test scripts using the MQTT plugin

  1. Create a thread group under the test plan.

JMeter create thread group

  1. Add "MQTT Connection Sampler" (i.e. "MQTT Connect") under the thread group

JMeter adds MQTT connection sampler

  1. Add a "sync timer" under the MQTT connection sampler to ensure all threads start establishing connections at the same time.

JMeter add synchronous timer

  1. Add "Test Activity" under the thread group to control how long the connection remains after the connection is established.

JMeter add test activity

  1. Add "MQTT Disconnect Sampler" (ie "MQTT DisConnect") under the thread group to simulate the device being disconnected at the same time.

JMeter add MQTT disconnect sampler

  1. Create "Summary Report" and "View Results Tree" listeners under the test plan to check the JMeter request results.

JMeter Summary Report

JMeter view result tree

execution of tests

Debug and verify the prepared script, and after confirming that the connectivity of the MQTT Broker and the script running logic are as expected, change the number of thread groups on the thread group page to 400, and click the Start button on the page to execute the test.

JMeter Start

Looking at the connection results, the aggregated report shows that the throughput is 394.9/s, that is, 400 clients connect simultaneously within 1 second.

JMeter Summary Report 2

JMeter View Sampler Results

Log in to the EMQX Dashboard page, as shown below:

EMQX Dashboard

Attachment: Sample Script

Readers can download the test script to run and view the results.

Copyright statement: This article is original by EMQ, please indicate the source when reprinting.

Original link: https://www.emqx.com/zh/blog/test-mqtt-connection-with-jmeter

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324079947&siteId=291194637