Skip to main content

taosBenchmark

Introduction

taosBenchmark is a performance testing application for TDengine. taosBenchmark can test insertion, query and subscription functions of TDengine, it can simulate a large amount of data generated by a large number of devices, and it can also flexibly control the number of columns, data types, threads, etc. Previously called taosdemo, it is now renamed taosBenchmark. The installer provides taosdemo as a soft link to taosBenchmark. Configuration, one is command line configuration and the other is JSON file.

CLI

option namedescription
-f/--fileJSON configuration file, cannot be used with other command line parameters
-c/--config-dirThe default path to the configuration file is /etc/taos/
-h/--hostThe FQDN to connect to the taosd server, the default value is localhost.
-P/--portThe port number to connect to the taosd server, the default value is 6030.
-I/--interfaceHow taosBenchmark inserts data, the default value is taosc.
-u/--userThe username to connect to the taosd server, the default value is root.
-p/--passwordThe password to connect to the taosd server, the default value is taosdata.
-o/--outputSpecify the path of the result output file, the default value is ./output.txt.
-T/--threadSpecify the number of threads to insert the data, the default value is 8
-i/--insert-intervalThe insertion interval for interline insertion mode, in ms, the default value is 0.
-S/--timestampstepThe insert timestamp step for each row in each sub-table in ms, the default value is 1
-B/--interlace-rowsThe number of interleaved rows to insert into the sub-table
-r/--rec-per-reqThe number of rows per insert request, the default is 30000
-t/--tablesThe number of sub-tables, the default value is 10000.
-n/--recordsThe number of records to insert per sub-table, the default value is 10000.
-d/--databaseThe name of the database, the default value is test.
-l/--columnsThe number of columns in the sub-table, will use int data type columns.
-A/--tag-typeThe data type of the tag of the sub-table.
-b/--data-typeThe data type of the column of the sub-table.
-w/--binwidthAdjusts the default length of nchar and binary data types, the default value is 64.
-m/--table-prefixThe prefix of the sub-table name, the default value is d
-E/--escape-characterUse escape characters in super table and sub table names, optional.
-C/--chineseWhether nchar and binary are basic Unicode Chinese characters, optional.
-N/--normal-tableCreate only normal tables, not super tables, optional.
-M/--randomWhether to use random data source, optional.
-x/--aggr-funcQuery aggregate function after insert, optional.
-y/--answer-yesContinue via confirmation prompt, optional.
-R/--disorder-rangeRange of out-of-order timestamps, based on database precision, default is 1000
-O/--disorderThe probability of inserting data with out-of-order timestamp, default is 0.
-F/--prepare_randThe number of random numbers to produce random data, default is 10000
-a/--replicaThe number of copies to create the database, default is 1.
-V/--versionDisplay version information and exit
-?/--helpShow help information and exit.

JSON

1、insert json configuration file

{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"connection_pool_size": 8,
"thread_count": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 100,
"num_of_records_per_req": 100,
"prepared_rand": 10000,
"chinese":"no",
"databases": [{
"dbinfo": {
"name": "db",
"drop": "yes",
"replica": 1,
"days": 10,
"cache": 16,
"blocks": 8,
"precision": "ms",
"keep": 3650,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
},
"super_tables": [{
"name": "stb",
"child_table_exists":"no",
"childtable_count": 100,
"childtable_prefix": "stb_",
"escape_character": "yes",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"line_protocol": "line",
"insert_rows": 100000,
"childtable_limit": 10,
"childtable_offset":100,
"interlace_rows": 0,
"insert_interval":0,
"partial_col_num": 0,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 10,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [{"type": "INT", "name": "id"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}],
"tags": [{"type": "TINYINT", "count":2, "max": 10, "min": 98}, {"type": "BINARY", "len": 16, "count":5, "values":["beijing","shanghai"]}]
}]
}]
}

Parameters

GroupOption NameDescription
filetypefiletype, specifies which test, for insert test, it needs to be insert.
cfgdirThe directory where the taosd configuration file is located, the default value is /etc/taos.
hostThe FQDN of the taosd server, the default is localhost.
portThe port number of the taosd server, the default is 6030.
userThe username to connect to the taosd server, default is root.
passwordThe password to connect to the taosd server, default is taosdata.
connection_pool_sizeThe size of the taos connection pool, the default is the number of threads.
thread_countThe number of threads to insert and create tables, defaults to 8.
result_fileThe path to the file where the output will be saved, defaults to . /output.txt.
confirm_parameter_promptPasses a confirmation prompt during execution, defaults to none.
insert_intervalThe interval for inserting interlace mode, default is 0.
interlace_rowsThe number of interleaved rows per child table, default is 0.
num_of_records_per_reqThe number of records per request, the default is 30000.
prepare_randThe number of randomly generated data, the default is 10000
chineseBoth nchar and binary are rand Chinese, default is no.
dbinfonameThe database name, required
dbinfodropWhether to delete the database before inserting tests.
dbinforeplicaThe number of replicas, the default value is 1.
dbinfodaysThe span of time to store data in the file, the default value is 10.
dbinfocacheThe size of the memory blocks in MB, the default value is 16.
dbinfoblocksThe number of memory blocks per vnode(tsdb) for the cache size, the default is 6.
dbinfoprecisionThe database time precision, the default value is "ms".
dbinfokeepThe number of days to keep the data, the default value is 3650.
dbinfominRowsThe minimum number of records in the file block, the default value is 100
dbinfominRowsThe maximum number of records in the file block, the default value is 4096.
dbinfocompThe file compression flag, the default value is 2.
dbinfowalLevelThe wal level, the default value is 1.
dbinfocachelastWhether to allow the last record of each table to be kept in memory, with a default value of 0
dbinfoquorumThe number of confirmations required for asynchronous writes, the default is 1.
dbinfofsyncThe interval for fsync when wal is set to 2, in ms, default is 3000.
dbinfoupdateWhether to support data updates, the default is 0.
super_tablesnameThe name of the super table, must be filled in.
super_tableschild_table_existsWhether the child table already exists, default is no.
super_tableschild_table_countThe number of child tables, required.
super_tableschild_table_prefixThe prefix of the child table name, required.
super_tablesescape_characterThe names of the super and child tables include escape characters, default is no.
super_tablesauto_create_tableWhether the SQL statement automatically creates sub-tables.
super_tablesbatch_create_tbl_numThe number of sub-tables to create for each request, default is 10.
super_tablesdata_sourceData resource type, options: rand, sample.
super_tablesinsert_modeInsert mode, options: taosc, rest, stmt, sml, default is taosc.
super_tablesnon-stop_modeWhether the insertion mode is a continuous non-stop write, default is no
super_tablesline_protocolLine protocol, optional: line, telnet, json, default is line.
super_tablestcp_transferWhether to use tcp or http protocol, default is http.
super_tablesinsert_rowsThe number of rows in each sub-table, default is 0.
super_tableschildtable_offsetThe offset of the child table.
super_tableschildtable_limitThe number of child tables to insert data into.
super_tablesinterlace_rowsThe interval rows of each child table, default is 0.
super_tablesinsert_intervalThe insert interval between two requests, valid when interlace_rows is greater than 0.
super_tablespartial_col_numSpecifies the number of columns to be written to, default is 0.
super_tablesdisorder_ratioThe data ratio for disorder timestamps, default is 0
super_tablesdisorder_rangeThe range of the disorder timestamp, valid only if disorder_ratio is greater than 0, defaults to 1000.
super_tablestimestamp_stepThe timestamp step for each record, defaults to 1.
super_tablesstart_timestampThe timestamp start value for each sub-table, the default is now.
super_tablessample_formatThe type of the sample data file, now only csv is supported.
super_tablessample_fileThe sample file, only valid if data_source is "sample".
super_tablesuse_sample_tsWhether the sample file contains a timestamp, defaults to no.
super_tablestags_fileSame principle as sample_file, tags data sample file, only supports taosc, rest insert mode.
columns/tagstypeData type, required
columns/tagslenThe length of the data, default is 8.
columns/tagscountThe number of consecutive columns, default is 1.
columns/tagsnameThe name of this column, the consecutive column name will be name_#<number>.
columns/tagsminThe minimum value of the numeric data type column/tag
columns/tagsmaxThe maximum value of the numeric data type column/label
columns/tagsvaluesnchar/binary The values of the columns/tags will be chosen randomly from the values.

2、Query test json configuration file

{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "db",
"query_times": 2,
"query_mode": "taosc",
"specified_table_query": {
"query_interval": 1,
"concurrent": 3,
"sqls": [
{
"sql": "select last_row(*) from stb0 ",
"result": "./query_res0.txt"
},
{
"sql": "select count(*) from stb00_1",
"result": "./query_res1.txt"
}
]
},
"super_table_query": {
"stblname": "stb1",
"query_interval": 1,
"threads": 3,
"sqls": [
{
"sql": "select last_row(ts) from xxxx",
"result": "./query_res2.txt"
}
]
}
}

Query test JSON file's parameters

GroupOptionsDescription
filetypefile type to specify which kind of test, for query test, required
cfgdirthe directory where taos configuration file in
hostFQDN of taosd server, default is localhost
portport number of taosd server, default is 6030
userusername to connect taosd server, default is root
passwordpassword to connect taosd server, default is taosdata
confirm_parameter_promptpass the confirmation prompt during execution, the default is no
databasesname of database, required
query_timesnumber of query times
query_modequery mode, options: taosc and rest, default is taosc
specified_table_query/super_table_queryquery_intervalquery interval, unit is second, default is 0
specified_table_query/super_table_queryconcurrent/threadsnumber of thread to execute sql, default is 1
super_table_querystblnamesupertable name, required
sqlssqlsql command, required
sqlsresultresult file for query result, empty for none

3、Subscribe json configuration file

{
"filetype":"subscribe",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"databases": "db",
"confirm_parameter_prompt": "no",
"specified_table_query":
{
"concurrent":1,
"interval":0,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from stb00_0 ;",
"result": "./subscribe_res0.txt"
}
]
},
"super_table_query":
{
"stblname": "stb0",
"threads":1,
"interval":10000,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from xxxx where ts > '2021-02-25 11:35:00.000' ;",
"result": "./subscribe_res1.txt"
}]
}
}

Subscribe test JSON file's parameters

GroupOptionsDescription
filetypefile type to specify which kind of test, for subscribe test, required
cfgdirthe directory of taos configuration file
hostFQDN of taosd server, default is localhost
portport number of taosd server, default is 6030
userusername to connect taosd server, default is root
passwordpassword to connect taosd server, default is taosdata
databasesdatabase name, required
confirm_parameter_promptwhether pass the confirmation prompt during execution
specified_table_query/super_table_queryconcurrent/threadsnumber of thread to execute sqls, default is 1
specified_table_query/super_table_queryintervalinterval to execute subscribe, default is 0
specified_table_query/super_table_queryrestartno: continue previous subscription, yes: start a new subscription
specified_table_query/super_table_querykeepProgresswhether keep the subscribe progress
specified_table_query/super_table_queryresubAfterConsumewhether unsubscribe and then subscribe again
super_table_querystblnamename of supertable, required
sqlssqlsql command, required
sqlsresultresult file for query result, empty for none

Parameter specifics

return

insert mode

Options are taosc, rest, stmt, sml, sml-rest, corresponding to c-interface, restful, parameter binding, schemaless c-interface, taosAdapter schemaless write

insert interval

Only works if interlace rows is greater than 0. Means that the thread will wait for that value for as long as it takes before doing the next round of writes after inserting interlace rows for each child table.

partial col num

If the value is 5, only the first 5 columns are written to, only if insert_mode is taosc and rest, and 0 is written to all columns.

batch create tbl num

The number of batches to create the child table, default is 10.

Note: The actual number of batches may not be the same as this value. When the executed SQL statement is longer than the maximum supported length, it will be automatically truncated and re-executed to continue creating.

auto create table

Only when insert_mode is taosc, rest, stmt and childtable_exists is "no", this parameter means execute the written SQL statement, if it is " yes" then insert into tb using stb tags (xxx,xxx,...) values (xxx,xxx,...) This format, if "no", would be insert into tb values (xxx,xxx,...) The former does not need to create a sub-table in advance, the latter does.

interlace rows

If its value is 0, it means insert sub-table by sub-table, if its value is greater than zero, for example, 5, it will insert first to the first subtable with 5 rows, then the second subtable with 5 rows, then the third, and so on. After all sub-tables have been written to with 5 records, the thread will continue writing from the first sub-table, and so on.

record per request

The number of rows included in each insert request/api call is also the batch count. When the batch count is too large, the taos client will return the corresponding error message, and this number needs to be adjusted to meet the write requirement.

columns

If both this parameter and -b/--data-type are set, the number of columns of the column type set by this parameter and -b/--data-type will be compared, if the former is greater than the latter, for example: -l 5 -b float,double, then the last column will be FLOAT,DOUBLE,INT,INT,INT. If the former is less than or equal to the latter, for example: -l 3 -b float,double,float,bigint, then the last column is FLOAT,DOUBLE,FLOAT,BIGINT.

tag type

Set the tag type of the super table, nchar and binary can also set the length, for example:

taosBenchmark -A INT,DOUBLE,NCHAR,BINARY(16)

The default is INT,BINARY(16).

Note: In some shells, such as bash, "()" needs to be escaped, so the above command should be

taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)

data type

Same as -A/--tag-type but for columns, defaults to FLOAT,INT,FLOAT

random

By default, the data is the data of the collection point of the analog meter with a specific size range of data values. If the sub-parameter is configured, the data will be randomly generated from the largest supported plus or minus 32-bit integer. If there are other parameters to modify the table structure, such as -l, -b, -A, etc... The data will be automatically generated randomly from the largest supported plus or minus 32-bit integers.

disorder ratio

The probability of random disorder timestamps, up to 50, i.e. 50%. The random disorder timestamp is the timestamp within a random disorder-range backwards of the timestamp of the current data to be inserted.

disorder range

Valid only if -O/--disorder is greater than 0, in the same units as the database's time precision.

prepared rand

As the number of random data pre-generated by the data source, a small prepared_rand will save memory, but will reduce the variety of data. If it is 1, then all data of the same type is generated equally.

connection pool size

All interactions with taos c clients require taos instances, which are created in advance to prevent failures due to interruptions during operation, this value determines the number of taos instances to be created in advance. If not configured, it is the same as the number of threads.

data source

The source of the data, which by default is randomly generated by taosBenchmark and can be configured as sample, i.e. data from the file specified with the sample_file parameter.

line protocol

Line protocol, only if insert_mode is sml and sml-rest, options are line, telnet, json.

non stop mode

If "yes", insert_rows will not work until Ctrl + C stops the program, then writing will stop.

Note: even though insert_rows is invalid, it must be a non-zero positive integer.

tcp transfer

Only works if insert_mode is sml-rest and line-protocol is telnet, two protocols are supported: tcp and http, default is http.

normal table

Only available when insert_mode is taosc, stmt, rest mode, no super table is created, only normal table is created.

childtable limit

Only works if childtable_exists is yes, for use with the statement select tbname from stable limit x offset y; The value x of limit in the statement ``` is the number of existing child tables to get inserted.

childtable offset

Only works if childtable_exists is yes, for the use of the statement select tbname from stable limit x offset y; to get the offset y of the inserted child table.

sample file

Whether to use data in csv format as data source, only when data_source is sample.

If the number of rows in the csv file is smaller than prepared_rand, then the csv file data will be read cyclically until it is the same as prepared_rand, if it is larger, then only the number of rows of prepared_rand will be read. If it is greater than that, only the rows with the number of prepared_rand will be read.

use sample ts

Only works when data_source is sample. sample_file specifies whether the csv file contains the first column timestamp, the default is no. If yes, the timestamp of the first column of the csv file is used. rows will be invalid.

tags file

Only works when insert_mode is taosc, rest.

Note: The principle here is similar to sample-file, the final tag value is related to the childtable_count, if the tag data rows in the csv file are smaller than the given number of child tables, then the csv file data will be read cyclically until the number of child tables is the same, if it is larger, then only the childtable_count rows of tag data.

type

Please refer to the officially supported data types for optional values.

Note: JSON data type is special, only in tags can be selected, and there is only one JSON tag column, at this time count and len represent the meaning of the number of key-value pairs within the JSON tag and the length of the value of each KV pair, respectively. The default value is string.

count

For example, if we want to test the performance of 4096 columns, instead of listing 4096 columns, we can just use "count": 4096.

len

The length of this data type, valid for NCHAR, BINARY and JSON data types, if configured for other data types, if it is 0, it means the column is always written with null value, if it is other numbers, it is meaningless and not recommended.

name

The name of the column, if used together with count, e.g. ```"name": "current", "count":3``, then the names of the 3 columns are current, current_2. current_3

sql

For the query SQL of super table, keep "xxxx" in the SQL command, the program will replace it with all the sub-table names of the super table automatically. Replace it with all the sub-table names in the super table.