MatrixBench: Data Simulation and Load Testing Tool

MatrixBench, abbreviated as mxbench, is a performance testing and data simulation tool for MatrixDB's streaming data ingestion service. It can rapidly generate random data based on specified parameters such as number of devices, time range, and number of metrics, then insert the data into MatrixDB at high speed via MatrixGate. The tool is located in the MatrixDB installation directory under bin/mxbench.

MatrixBench provides a rich set of parameters to meet various testing requirements. The total number of devices is defined by the tag-range parameter, with generated data evenly distributed across all devices. Timestamps start from ts-begin. For every ts-rps rows inserted, the timestamp advances by one second. The number of metrics per row is controlled by columns-per-row. The metric data type is specified by column-data-type, which can be simple types or complex types such as JSON or Array. For complex types, the individual value type within each column is defined by point-data-type. Below is a detailed list of startup parameters:

Parameter Value Description
--table-name tableName Target table name (required)
--database postgres (default) Target database name
--http-host localhost (default) Hostname of MatrixGate
--http-port 8086 (default) Port number of MatrixGate
--parallel Number of CPU cores (default) Maximum number of connections to MatrixGate
--batch-size 1000 (default) Number of data rows per request per connection
--tag-range 50000 (default) Total number of target devices for data loading
--ts-rps 25000 (default) Timestamp increment rate; time increases by one second after inserting this many rows
--ts-begin Current time (default) Start timestamp for generated data
--format text (default) Data format: text or csv
--time-format unix-second (default) Timestamp unit: unix-second, unix-ms, unix-nano, or raw
--delimiter | (default) Column delimiter in each data row
--columns-per-row 100 (default) Number of columns per data row
--column-data-type simple (default) Metric column type: supports simple (e.g., float/int), and composite types json, array
--points-per-column 3 (default) Number of metric values per column when --column-data-type is json or array
--point-data-type float8 (default) Data type of each metric value within a composite column; supports int, float4, float8
--use-gzip FALSE (default) Whether to enable GZIP compression when sending data


Usage Example

Create a table in the demo database:

create table sensor_data(
    "time" timestamp with time zone not null,
    tag_id integer,
    tag_value double precision)
Distributed By(tag_id);

Start MatrixGate:

mxgate config --db-master-port 5432 --db-database demo --interval 150 > ~/mxgate.conf
mxgate start --config ~/mxgate.conf

Run mxbench:

mxbench --database demo --table-name sensor_data --columns-per-row 1 --column-data-type simple --point-data-type float8

After running mxbench, you will see output similar to:

Send to http://127.0.0.1:8086
Parallel level is 64
Point format is simple
Tag range is 50000
TIMESTAMP step is 40000 nano second
16036-03-16 16:55:04: sent OK: 4282000, ERR 0, Lat 147.67ms last10s 147.67ms, Row/s: 428200, last10s 428200
16036-03-16 16:55:14: sent OK: 8506000, ERR 0, Lat 148.12ms last10s 148.58ms, Row/s: 425300, last10s 422400
16036-03-16 16:55:24: sent OK: 12794000, ERR 0, Lat 148.26ms last10s 148.52ms, Row/s: 426466, last10s 428800
  • OK: Total number of rows successfully sent and inserted since mxbench started.
  • ERR: Total number of failed rows.
  • Lat: Average latency since startup.
  • last10s after Lat: Average latency over the last 10 seconds.
  • Row/s: Average number of rows sent per second since startup.
  • last10s after Row/s: Average send rate over the last 10 seconds.

Once started, mxbench continues load testing until the user presses Ctrl+C to terminate the process.