Benchmark Tool

1. Basic Overview

IoT-benchmark is a time-series database benchmarking tool developed in Java for big data environments. It was developed and open-sourced by the School of Software, Tsinghua University. The tool is user-friendly, supports various write and query methods, allows storing test information and results for further queries or analysis, and integrates with Tableau for visualizing test results.

Figure 1-1 illustrates the test benchmark process and its extended functionalities, all of which can be streamlined by IoT-benchmark. It supports a variety of workloads, including write-only, read-only, and mixed write-and-read operations. Additionally, it offers software and hardware system monitoring, performance metric measurement, automated database initialization, test data analysis, and system parameter optimization.

Figure 1-1 IoT-benchmark Test Benchmark Process

IoT-benchmark adopts the modular design concept of the YCSB test tool, which separates workload generation, performance measurement, and database interface components. Its modular structure is illustrated in Figure 1-2. Unlike YCSB-based testing tools, IoT-benchmark introduces a system monitoring module that supports the persistence of both test data and system metrics. It also includes load-testing functionalities specifically designed for time-series data scenarios, such as batch writes and multiple out-of-order data insertion modes for IoT environments.

Figure 1-2 IoT-benchmark Modular Design

Supported Databases

Currently, IoT-benchmark supports the following time series databases, versions and connection methods:

DatabaseVersionConnection mmethod
IoTDBv1.x v2.xJDBC, SessionByTablet, SessionByRecord, SessionByRecords
InfluxDBv1.x v2.xSDK
TimescaleDB--JDBC
OpenTSDB--HTTP Request
QuestDBv6.0.7JDBC
TDenginev2.2.0.2JDBC
VictoriaMetricsv1.64.0HTTP Request
KairosDB--HTTP Request

2. Installation and Operation

2.1 Prerequisites

  1. Java 8
  2. Maven 3.6+
  3. The corresponding appropriate version of the database, such as Apache IoTDB 2.0

2.2 How to Obtain

  • Binary package: Visit https://github.com/thulab/iot-benchmark/releases to download the installation package. Extract the compressed file into a desired folder for use.

  • Source Code Compilation (for Apache IoTDB 2.0 testing):

    • Compile the latest IoTDB Session package: Download the IoTDB source code from https://github.com/apache/iotdb/tree/rc/2.0.5 and run the following command in the root directory to compile the latest IoTDB Session package:

       mvn clean package install -pl session -am -DskipTests
      
    • Compile the IoT-benchmark test package: Download the source code from https://github.com/thulab/iot-benchmark and run the following command in the root directory to compile the Apache IoTDB 2.0 test package:.

       mvn clean package install -pl iotdb-2.0 -am -DskipTests
      
    • The compiled test package will be located at:

    ./iotdb-2.0/target/iotdb-2.0-0.0.1/iotdb-2.0-0.0.1
    

2.3 Test Package Structure

The directory structure of the test package is shown below. The test configuration file is conf/config.properties, and the test startup scripts are benchmark.sh (Linux & MacOS) and benchmark.bat (Windows). The detailed usage of the files is shown in the table below.

-rw-r--r--. 1 root root  2881 Jan  10 01:36 benchmark.bat
-rwxr-xr-x. 1 root root   314 Jan  10 01:36 benchmark.sh
drwxr-xr-x. 2 root root    24 Jan  10 01:36 bin
-rwxr-xr-x. 1 root root  1140 Jan  10 01:36 cli-benchmark.sh
drwxr-xr-x. 2 root root   107 Jan  10 01:36 conf
drwxr-xr-x. 2 root root  4096 Jan  10 01:38 lib
-rw-r--r--. 1 root root 11357 Jan  10 01:36 LICENSE
-rwxr-xr-x. 1 root root   939 Jan  10 01:36 rep-benchmark.sh
-rw-r--r--. 1 root root    14 Jan  10 01:36 routine
NameFileUsage
benchmark.bat-Startup script on Windows
benchmark.sh-Startup script on Linux/Mac
binstartup.shInitialization script folder
confconfig.propertiesTest scenario configuration file
lib-Dependency library
LICENSE-License file
cli-benchmark.sh-One-click startup script
routine-Automatic execution of multiple test configurations
rep-benchmark.sh-Automatic execution of multiple test scripts

2.4 Execution of Tests

  1. Modify the configuration file (conf/config.properties) according to test requirements. For example, to test Apache IoTDB 2.0, set the following parameter:

       DB_SWITCH=IoTDB-200-SESSION_BY_TABLET
    
  2. Ensure the target time-series database is running.

  3. Start IoT-benchmark to execute the test. Monitor the status of both the target database and IoT-benchmark during execution.

  4. Upon completion, review the results and analyze the test process.

2.5 Results Interpretation

All test log files are stored in the logs folder, while test results are saved in the data/csvOutput folder. For example, the following result matrix illustrates the test outcome:

  • Result Matrix:
    • OkOperation: Number of successful operations.
    • OkPoint: Number of successfully written points (for write operations) or successfully queried points (for query operations).
    • FailOperation: Number of failed operations.
    • FailPoint: Number of failed write points.
  • Latency (ms) Matrix:
    • AVG: Average operation latency.
    • MIN: Minimum operation latency.
    • Pn: Quantile values of the overall operation distribution (e.g., P25 represents the 25th percentile, or lower quartile).

3. Main Parameters

3.1 IoTDB Service Model

The IoTDB_DIALECT_MODE parameter supports two modes: tree and table. The default value is tree.

  • For IoTDB 2.0 and later versions, the IoTDB_DIALECT_MODE parameter must be specified, and only one mode can be set for each IoTDB instance.
  • IoTDB_DIALECT_MODE = tree:
    • The number of devices must be greater than or equal to the number of databases.

3.2 Working Mode

The BENCHMARK_WORK_MODE parameter supports four operational modes:

  1. General Test Mode (testWithDefaultPath): Configured via the OPERATION_PROPORTION parameter to support write-only, read-only, and mixed read-write operations.
  2. Data Generation Mode (generateDataMode): Generates a reusable dataset, which is saved to FILE_PATH for subsequent use in the correctness write and correctness query modes.
  3. Single Database Correctness Write Mode (verificationWriteMode): Verifies the correctness of dataset writing by writing the dataset generated in data generation mode. This mode supports only IoTDB v1.0+ and InfluxDB v1.x.
  4. Single Database Correctness Query Mode (verificationQueryMode): Verifies the correctness of dataset queries after using the correctness write mode. This mode supports only IoTDB v1.0+ and InfluxDB v1.x.

Mode configurations are shown in the following below:

Mode nameBENCHMARK_WORK_MODEDescriptionRequired Configuration
General test modetestWithDefaultPathSupports multiple read and write mixed load operations.OPERATION_PROPORTION
Generate data modegenerateDataModeGenerates datasets recognizable by IoT-benchmark.FILE_PATH and DATA_SET
Single database correctness write modeverificationWriteModeWrites datasets for correctness verification.FILE_PATH and DATA_SET
Single database correctness query modeverificationQueryModeQueries datasets to verify correctness.FILE_PATH and DATA_SET

3.3 Server Connection Information

Once the working mode is specified, the following parameters must be configured to inform IoT-benchmark of the target time-series database:

ParameterTypeExampleDescription
DB_SWITCHStringIoTDB-200-SESSION_BY_TABLETSpecifies the type of time-series database under test.
HOSTString127.0.0.1Network address of the target time-series database.
PORTInteger6667Network port of the target time-series database.
USERNAMEStringrootLogin username for the time-series database.
PASSWORDStringrootPassword for the database login user.
DB_NAMEStringtestName of the target time-series database.
TOKENString-Authentication token (used for InfluxDB 2.0).

3.4 Write Scenario Parameters

ParameterTypeExampleDescription
CLIENT_NUMBERInteger100Total number of clients used for writing.
GROUP_NUMBERInteger20Number of databases (only applicable for IoTDB).
DEVICE_NUMBERInteger100Total number of devices.
SENSOR_NUMBERInteger300Total number of sensors per device. (Control the number of attribute columns if you use the IoTDB table model)
INSERT_DATATYPE_PROPORTIONString1:1:1:1:1:1:0:0:0:0Ratio of data types: BOOLEAN:INT32:INT64:FLOAT:DOUBLE:TEXT:STRING:BLOB:TIMESTAMP:DATE.
POINT_STEPInteger1000Time interval (in ms) between generated data points.
OP_MIN_INTERVALInteger0Minimum execution interval for operations (ms): if the operation takes more than the value, the next one will be executed immediately, otherwise wait (OP_MIN_INTERVAL - actual execution time) ms; if it is 0, the parameter is not effective; if it is -1, its value is consistent with POINT_STEP
IS_OUT_OF_ORDERBooleanfalseSpecifies whether to write data out of order.
OUT_OF_ORDER_RATIOFloating point number0.3Proportion of out-of-order data.
BATCH_SIZE_PER_WRITEInteger1Number of data rows written per batch.
START_TIMETime2022-10-30T00:00:00+08:00Start timestamp for data generation.
LOOPInteger86400Total number of write operations: Each type of operation will be divided according to the proportion defined by OPERATION_PROPORTION
OPERATION_PROPORTIONCharacter1:0:0:0:0:0:0:0:0:0:0Ratio of operation types (write:Q1:Q2:...:Q10).

3.5 Query Scenario Parameters

ParameterTypeExampleDescription
QUERY_DEVICE_NUMInteger2Number of devices involved in each query statement.
QUERY_SENSOR_NUMInteger2Number of sensors involved in each query statement.
QUERY_AGGREGATE_FUNCharactercountAggregate functions used in queries (COUNT, AVG, SUM, etc.).
STEP_SIZEInteger1Time interval step for time filter conditions.
QUERY_INTERVALInteger250000Time interval between query start and end times.
QUERY_LOWER_VALUEInteger-5Threshold for conditional queries (WHERE value > QUERY_LOWER_VALUE).
GROUP_BY_TIME_UNITInteger20000The size of the group in the GROUP BY statement
LOOPInteger10Total number of query operations: Each type of operation will be divided according to the proportion defined by OPERATION_PROPORTION
OPERATION_PROPORTIONCharacter0:0:0:0:0:0:0:0:0:0:1Ratio of operation types (write:Q1:Q2:...:Q10).

3.6 Query Types and Example SQL

NumberQuery TypeIoTDB Sample SQL
Q1Precise Point Queryselect v1 from root.db.d1 where time = ?
Q2Time Range Queryselect v1 from root.db.d1 where time > ? and time < ?
Q3Time Range with Value Filterselect v1 from root.db.d1 where time > ? and time < ? and v1 > ?
Q4Time Range Aggregation Queryselect count(v1) from root.db.d1 where and time > ? and time < ?
Q5Full-Time Range with Filteringselect count(v1) from root.db.d1 where v1 > ?
Q6Range Aggregation with Filterselect count(v1) from root.db.d1 where v1 > ? and time > ? and time < ?
Q7Time Grouping Aggregationselect count(v1) from root.db.d1 group by ([?, ?), ?, ?)
Q8Latest Point Queryselect last v1 from root.db.d1
Q9Descending Range Queryselect v1 from root.sg.d1 where time > ? and time < ? order by time desc
Q10Descending Range with Filterselect v1 from root.sg.d1 where time > ? and time < ? and v1 > ? order by time desc

3.7 Test process and test result persistence

IoT-benchmark currently supports persisting the test process and test results through configuration parameters.

ParameterTypeExampleDescription
TEST_DATA_PERSISTENCEStringNoneSpecifies the result persistence method. Options: None, IoTDB, MySQL, CSV.
RECORD_SPLITBooleantrueWhether to split results into multiple records. (Not supported by IoTDB currently.)
RECORD_SPLIT_MAX_LINEInteger10000000Maximum number of rows per record (10 million rows per database table or CSV file).
TEST_DATA_STORE_IPString127.0.0.1IP address of the database for result storage.
TEST_DATA_STORE_PORTInteger6667Port number of the output database.
TEST_DATA_STORE_DBStringresultName of the output database.
TEST_DATA_STORE_USERStringrootUsername for accessing the output database.
TEST_DATA_STORE_PWStringrootPassword for accessing the output database.

Result Persistence Details

  • CSV Mode: If TEST_DATA_PERSISTENCE is set to CSV, a data folder is generated in the IoT-benchmark root directory during and after test execution. This folder contains:
    • csv folder: Records the test process.
    • csvOutput folder: Stores the test results.
  • MySQL Mode: If TEST_DATA_PERSISTENCE is set to MySQL, IoT-benchmark creates the following tables in the specified MySQL database:
    • Test Process Table:
      1. Created before the test starts.
      2. Named as: testWithDefaultPath_<database_name>_<remarks>_<test_start_time>.
    • Configuration Table:
      1. Named CONFIG.
      2. Stores the test configuration.
      3. Created if it does not exist.
    • Final Result Table:
      1. Named FINAL_RESULT.
      2. Stores the test results after test completion.
      3. Created if it does not exist.

3.8 Automation Script

One-Click Script Startup

The cli-benchmark.sh script allows one-click startup of IoTDB, IoTDB Benchmark monitoring, and IoTDB Benchmark testing. However, please note that this script will clear all existing data in IoTDB during startup, so use it with caution.

Steps to Run:

  1. Edit the IOTDB_HOME parameter in cli-benchmark.sh to the local IoTDB directory.
  2. Start the test by running the following command:
> ./cli-benchmark.sh
  1. After the test completes:
  2. Check test-related logs in the logs folder.
  3. Check monitoring-related logs in the server-logs folder.

Automatic Execution of Multiple Tests

Single tests are often insufficient without comparative results. Therefore, IoT-benchmark provides an interface for executing multiple tests in sequence.

  1. Routine Configuration: Each line in the routine file specifies the parameters that change for each test. For example:

       LOOP=10 DEVICE_NUMBER=100 TEST
       LOOP=20 DEVICE_NUMBER=50 TEST
       LOOP=50 DEVICE_NUMBER=20 TEST
    

In this example, three tests will run sequentially with LOOP values of 10, 20, and 50.

Then the test process with 3 LOOP parameters of 10, 20, and 50 is executed in sequence.

Important Notes:

  • Multiple parameters can be changed in each test using the format:

      LOOP=20 DEVICE_NUMBER=10 TEST
    
  • Avoid unnecessary spaces.

  • The TEST keyword marks the start of a new test.

  • Changed parameters persist across subsequent tests unless explicitly reset.

  1. Start the Test: After configuring the routine file, start multi-test execution using the following command

       > ./rep-benchmark.sh
    

Test results will be displayed in the terminal.

Important Notes:

  • Closing the terminal or losing the client connection will terminate the test process.

  • To run the test as a background daemon, execute:

      > ./rep-benchmark.sh > /dev/null 2>&1 &
    
  • To monitor progress, check the logs:

      > cd ./logs
      > tail -f log_info.log
    

4. Use Case

We take the application of CRRC Qingdao Sifang Vehicle Research Institute Co., Ltd. as an example, and refer to the scene described in “Apache IoTDB in Intelligent Operation and Maintenance Platform Storage” for practical operation instructions.

Test objective: Simulate the actual needs of switching time series databases in the scene of CRRC Qingdao Sifang Institute, and compare the performance of the expected IoTDB and KairosDB used by the original system.

Test environment: In order to ensure that the impact of other irrelevant services and processes on database performance and the mutual influence between different databases are eliminated during the experiment, the local databases in this experiment are deployed and run on multiple independent virtual servers with the same resource configuration. Therefore, this experiment set up 4 Linux (CentOS7 /x86) virtual machines, and deployed IoT-benchmark, IoTDB database, KairosDB database, and MySQL database on them respectively. The specific resource configuration of each virtual machine is shown in Table 4-1. The specific usage of each virtual machine is shown in Table 4-2.

Table 4-1 Virtual machine configuration information

Hardware Configuration InformationValue
OS systemCentOS7
number of CPU cores16
memory32G
hard disk200G
networkGigabit

Table 4-2 Virtual machine usage

IPUsage
172.21.4.2IoT-benchmark
172.21.4.3Apache-iotdb
172.21.4.4KaiosDB
172.21.4.5MySQL

4.1 Write Test

Scenario description: Create 100 clients to simulate 100 trains, each train has 3000 sensors, the data type is DOUBLE, the data time interval is 500ms (2Hz), and they are sent sequentially. Referring to the above requirements, we need to modify the IoT-benchmark configuration parameters as listed in Table 4-3.

Table 4-3 Configuration parameter information

Parameter NameIoTDB ValueKairosDB Value
DB_SWITCHIoTDB-013-SESSION_BY_TABLETKairosDB
HOST172.21.4.3172.21.4.4
PORT66678080
BENCHMARK_WORK_MODEtestWithDefaultPath
OPERATION_PROPORTION1:0:0:0:0:0:0:0:0:0:0
CLIENT_NUMBER100
GROUP_NUMBER10
DEVICE_NUMBER100
SENSOR_NUMBER3000
INSERT_DATATYPE_PROPORTION0:0:0:0:1:0
POINT_STEP500
OP_MIN_INTERVAL0
IS_OUT_OF_ORDERfalse
BATCH_SIZE_PER_WRITE1
LOOP10000
TEST_DATA_PERSISTENCEMySQL
TEST_DATA_STORE_IP172.21.4.5
TEST_DATA_STORE_PORT3306
TEST_DATA_STORE_DBdemo
TEST_DATA_STORE_USERroot
TEST_DATA_STORE_PWadmin
REMARKdemo

First, start the tested time series databases Apache-IoTDB and KairosDB on 172.21.4.3 and 172.21.4.4 respectively, and then start server resource monitoring through the ser-benchamrk.sh script on 172.21.4.2, 172.21.4.3 and 172.21.4.4 (Figure 4-1). Then modify the conf/config.properties files in the iotdb-0.13-0.0.1 and kairosdb-0.0.1 folders in 172.21.4.2 according to Table 4-3 to meet the test requirements. Use benchmark.sh to start the writing test of Apache-IoTDB and KairosDB successively.

img

Figure 4-1 Server monitoring tasks

For example, if we first start the test on KairosDB, IoT-benchmark will create a CONFIG data table in the MySQL database to store the configuration information of this test (Figure 4-2), and there will be a log output of the current test progress during the test execution (Figure 4-3) . When the test is completed, the test result will be output (Figure 4-3), and the result will be written into the FINAL_RESULT data table (Figure 4-4).

img

Figure 4-2 Test configuration information table

img img img img

Figure 4-3 Test progress and results

img

Figure 4-4 Test result table

Afterwards, we will start the test on Apache-IoTDB. The same IoT-benchmark will write the test configuration information in the MySQL database CONFIG data table. During the test execution, there will be a log to output the current test progress. When the test is completed, the test result will be output, and the result will be written into the FINAL_RESULT data table.

According to the test result information, we know that under the same configuration the write delay times of Apache-IoTDB and KairosDB are 55.98ms and 1324.45ms respectively; the write throughputs are 5,125,600.86 points/second and 224,819.01 points/second respectively; the tests were executed respectively 585.30 seconds and 11777.99 seconds. And KairosDB has a write failure. After investigation, it is found that the data disk usage has reached 100%, and there is no disk space to continue receiving data. However, Apache-IoTDB has no write failure, and the disk space occupied after all data is written is only 4.7G (as shown in Figure 4-5); Apache-IoTDB is better than KairosDB in terms of write throughput and disk occupation. Of course, there will be other tests in the follow-up to observe and compare from various aspects, such as query performance, file compression ratio, data security, etc.

img

Figure 4-5 Disk usage

So what is the resource usage of each server during the test? What is the specific performance of each write operation? At this time, we can visualize the data in the server monitoring table and test process recording table by installing and using Tableau. The use of Tableau will not be introduced in this article. After connecting to the data table for test data persistence, the specific results are as follows (taking Apache-IoTDB as an example):

img img

Figure 4-6 Visualization of testing process in Tableau

4.2 Query Test

Scenario description: In the writing test scenario, 10 clients are simulated to perform all types of query tasks on the data stored in the time series database Apache-IoTDB. The configuration is as follows.

Table 4-4 Configuration parameter information

Parameter NameExample
CLIENT_NUMBER10
QUERY_DEVICE_NUM2
QUERY_SENSOR_NUM2
QUERY_AGGREGATE_FUNcount
STEP_SIZE1
QUERY_INTERVAL250000
QUERY_LOWER_VALUE-5
GROUP_BY_TIME_UNIT20000
LOOP30
OPERATION_PROPORTION0:1:1:1:1:1:1:1:1:1:1

Results:

img

Figure 4-7 Query test results

4.3 Description of Other Parameters

In the previous chapters, the write performance comparison between Apache-IoTDB and KairosDB was performed, but if the user wants to perform a simulated real write rate test, how to configure it? How to control if the test time is too long? Are there any regularities in the generated simulated data? If the IoT-Benchmark server configuration is low, can multiple machines be used to simulate pressure output?

Table 4-5 Configuration parameter information

ScenarioParameterValueNotes
Simulate real write rateOP_INTERVAL-1You can also enter an integer to control the operation interval.
Specify test duration (1 hour)TEST_MAX_TIME3600000The unit is ms; the LOOP execution time needs to be greater than this value.
Define the law of simulated data: support all data types, and the number is evenly classified; support five data distributions, and the number is evenly distributed; the length of the string is 10; the number of decimal places is 2.INSERT_DATATYPE_PROPORTION1:1:1:1:1:1Data type distribution proportion
LINE_RATIO1linear
SIN_RATIO1Fourier function
SQUARE_RATIO1Square wave
RANDOM_RATIO1Random number
CONSTANT_RATIO1Constant
STRING_LENGTH10String length
DOUBLE_LENGTH2Decimal places
Three machines simulate data writing of 300 devicesBENCHMARK_CLUSTERtrueEnable multi-benchmark mode
BENCHMARK_INDEX0, 1, 3Take the writing parameters in the write test as an example: No. 0 is responsible for writing data of device numbers 0-99; No. 1 is responsible for writing data of device numbers 100-199; No. 2 is responsible for writing data of device numbers 200-299.