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
InfluxDBv1.x v2.0SDK
TimescaleDB--JDBC
OpenTSDB--HTTP Request
QuestDBv6.0.7JDBC
TDenginev2.2.0.2JDBC
VictoriaMetricsv1.64.0HTTP Request
KairosDB--HTTP Request
IoTDBv2.0 v1.x v0.13JDBC, SessionByTablet, SessionByRecord, SessionByRecords

2. Installation and Operation

Prerequisites

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

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.1 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:

      ```Bash
      ./iotdb-2.0/target/iotdb-2.0-0.0.1/iotdb-2.0-0.0.1
      ```
      

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

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.

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

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 = table:
    • The number of devices must be an integer multiple of the number of tables.
    • The number of tables must be an integer multiple of the number of databases.
  • IoTDB_DIALECT_MODE = tree:
    • The number of devices must be greater than or equal to the number of databases.

Key Parameters for IoTDB Service Model

Parameter nameTypeExampleSystem description
IoTDB_TABLE_NAME_PREFIXStringtable_Prefix for table names when IoTDB_DIALECT_MODE is set to table.
DATA_CLIENT_NUMBERInteger10Number of clients, must be an integer multiple of the table count.
SENSOR_NUMBERInteger10Controls the number of attribute columns in the table model.
IoTDB_TABLE_NUMBERInteger1Specifies the number of tables when using the table model.

Working M****ode

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

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).

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).

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).

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

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.

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:
    1. Check test-related logs in the logs folder.
    2. 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
    
  2. 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. Test Example

This example demonstrates how to configure and run an IoT-benchmark test with IoTDB 2.0 using the table model for writing and querying.

----------------------Main Configurations----------------------
BENCHMARK_WORK_MODE=testWithDefaultPath
IoTDB_DIALECT_MODE=TABLE
DB_SWITCH=IoTDB-200-SESSION_BY_TABLET
GROUP_NUMBER=1
IoTDB_TABLE_NUMBER=1
DEVICE_NUMBER=60
REAL_INSERT_RATE=1.0
SENSOR_NUMBER=10
OPERATION_PROPORTION=1:0:0:0:0:0:0:0:0:0:0:0
SCHEMA_CLIENT_NUMBER=10
DATA_CLIENT_NUMBER=10
LOOP=10
BATCH_SIZE_PER_WRITE=10
DEVICE_NUM_PER_WRITE=1
START_TIME=2025-01-01T00:00:00+08:00
POINT_STEP=1000
INSERT_DATATYPE_PROPORTION=1:1:1:1:1:1:0:0:0:0
VECTOR=true

Execution Steps:

  1. Ensure the target database (IoTDB 2.0) is running.
  2. Start IoT-benchmark using the configured parameters.
  3. Upon completion, view the test results.
Create schema cost 0.88 second
Test elapsed time (not include schema creation): 4.60 second
----------------------------------------------------------Result Matrix----------------------------------------------------------
Operation                okOperation              okPoint                  failOperation            failPoint                throughput(point/s)      
INGESTION                600                      60000                    0                        0                        13054.42                 
PRECISE_POINT            0                        0                        0                        0                        0.00                     
TIME_RANGE               0                        0                        0                        0                        0.00                     
VALUE_RANGE              0                        0                        0                        0                        0.00                     
AGG_RANGE                0                        0                        0                        0                        0.00                     
AGG_VALUE                0                        0                        0                        0                        0.00                     
AGG_RANGE_VALUE          0                        0                        0                        0                        0.00                     
GROUP_BY                 0                        0                        0                        0                        0.00                     
LATEST_POINT             0                        0                        0                        0                        0.00                     
RANGE_QUERY_DESC         0                        0                        0                        0                        0.00                     
VALUE_RANGE_QUERY_DESC   0                        0                        0                        0                        0.00                     
GROUP_BY_DESC            0                        0                        0                        0                        0.00                     
---------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------Latency (ms) Matrix--------------------------------------------------------------------------
Operation                AVG         MIN         P10         P25         MEDIAN      P75         P90         P95         P99         P999        MAX         SLOWEST_THREAD
INGESTION                41.77       0.95        1.41        2.27        6.76        24.14       63.42       127.18      1260.92     1265.72     1265.49     2581.91     
PRECISE_POINT            0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
TIME_RANGE               0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
VALUE_RANGE              0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
AGG_RANGE                0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
AGG_VALUE                0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
AGG_RANGE_VALUE          0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
GROUP_BY                 0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
LATEST_POINT             0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
RANGE_QUERY_DESC         0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
VALUE_RANGE_QUERY_DESC   0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
GROUP_BY_DESC            0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        0.00        
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------