Preface

The Internet of Things is developing rapidly with an explosive growth momentum. As the scale of equipment continues to grow and business logic becomes more complex, before the IoT platform is officially launched, it is necessary to verify the availability and reliability of the platform when a large number of devices are connected to ensure the quality of the system. Therefore, the value and necessity of IoT performance testing have gradually become prominent.

On the one hand, performance testing provides a basis for evaluating the IoT system and verifies it from multiple dimensions of design indicators, scalability and reliability; on the other hand, performance testing also helps optimize the IoT system, helping to find system performance bottlenecks early , Provide tuning suggestions. In addition, performance testing can also assist in the formulation of capacity plans and provide a reference for future expansion plans.

However, the Internet of Things system features a large amount of access devices, diversified protocols, complex integration architecture, and frequent cross-departmental development and collaboration, which also make the Internet of Things performance test face many challenges. This series of articles will take the IoT platform based on EMQ X as an example to introduce how to use performance testing tools to verify and test platform-related quality indicators.

Selection of test tools-Introduction to JMeter

We chose JMeter as our testing tool.

JMeter is an open source software under the Apache Foundation. It mainly implements performance testing by simulating concurrent loads. It is currently the mainstream performance testing tool in the open source community. It has the following advantages:

  • Built-in testing support for multiple protocols, such as TCP, HTTP/HTTPS, etc.
  • Provide a flexible plug-in extension mechanism and support third-party extensions to other protocols. For a wide variety of protocols in the Internet of Things system, you only need to customize and develop the required protocol business logic according to the JMeter framework requirements, and then you can easily put it into the JMeter plug-in library, and use JMeter's existing functions to perform the performance test of the protocol.
  • Have good community support.

JMeter installation

At present, the latest stable version of JMeter is 5.4.1. Since JMeter is based on Java, the 5.4.1 version of JMeter requires pre-installation of Java 8 and above support (available from the following address: https://www.oracle.com/ java/technologies/downloads ).

After installing Java, download JMeter from the official website: https://jmeter.apache.org/download_jmeter.cgi .

After the download is complete, decompress and enter the bin subdirectory of the decompressed directory. Depending on the operating system, run jmeter.bat (Windows system) or jmeter (Unix system). If all goes well, JMeter's script editing interface will be presented to you:

安装 JMeter

Next, we take HTTP as an example to see how to use JMeter to build and run a simple test case.

  1. Add a virtual user group (Thread Group): Right-click the test plan> Add> Thread (User)> Thread Group

    JMeter 添加虚拟用户组

    JMeter uses a single thread to simulate a user, the user group Thread Group refers to a group of users, as a virtual user group that simulates access to the system under test.

    The "Thread Number" in "Thread Properties" can be used to configure the number of concurrent users of the virtual user group. The higher the value, the greater the amount of concurrency; the "Number of Cycles" can be used to configure how many tests each virtual user performs.

    JMeter 线程属性

  2. Add the tested HTTP page: right click on the thread group> Add> Sampler> HTTP request

    JMeter 添加被测 HTTP 页面

    In the sample test script, we only use the default HTTP request settings to initiate an HTTP request to the bing website. You can make relevant configurations according to the actual situation.

    JMeter 添加被测 HTTP 页面2

  3. Add a result listener: right-click the thread group> Add> Listener> View the result tree

    The listener is not necessary in the actual running performance test, but it can help to visually see the test result in the process of writing the script, which is convenient for debugging. In this sample script, we will use "View Results Tree" to help view the response information of the request.

    JMeter 添加结果监听器

  4. Run the test.

    After saving the test script, click the "Start" button in the operation bar to start running the test script. It is recommended that the number of threads and the number of loops in the thread group be set smaller (for example, within 10) to avoid being banned.

    运行JMeter测试

Above, we have completed a simple HTTP test script. You can draw inferences and try other protocol tests. In the next article, we will introduce the various test components of JMeter in more detail, and use them together to build more complex test scenarios.


EMQX
336 声望436 粉丝

EMQ(杭州映云科技有限公司)是一家开源物联网数据基础设施软件供应商,交付全球领先的开源 MQTT 消息服务器和流处理数据库,提供基于云原生+边缘计算技术的一站式解决方案,实现企业云边端实时数据连接、移动、...