clickhouse-benchmark:
Command-line options
--query=QUERY— Query to execute. If this parameter is not passed,clickhouse-benchmarkwill read queries from standard input.--query_id=ID— Query Id.--query_id_prefix=ID_PREFIX— Query Id Prefix.--queries-format=FORMAT— Format of queries read from standard input. Possible values:tsv(default, one tab-escaped query per line) andscript(parse the input as a script of multiple queries separated by semicolons). Limitation ofscript:INSERT ... FORMATqueries must be on a single line.-c N,--concurrency=N— Number of queries thatclickhouse-benchmarksends simultaneously. Default value: 1.-C N,--max_concurrency=N— Gradually increases number of parallel queries up to specified value, making one report for every concurrency level.--precise— Enables precise per-interval reporting with weighted metrics.-d N,--delay=N— Interval in seconds between intermediate reports (to disable reports set 0). Default value: 1.-h HOST,--host=HOST— Server host. Default value:localhost. For the comparison mode you can use multiple-hkeys.-i N,--iterations=N— Total number of queries. Default value: 0 (repeat forever).-r,--randomize— Random order of queries execution if there is more than one input query.--arrival-rate=R— Enables the open-loop mode: queries arrive at random times at the average rate ofRqueries per second. A comma-separated list of rates, such as--arrival-rate=5,10,20, runs the benchmark for every rate one after another and makes one report per rate; it requires--iterationsor--timelimit.--max-in-flight=N— The maximum number of queries executing at the same time in the open-loop mode. Default value: 256.--seed=N— Seed of the random generator for the arrival times, the order of queries with--randomize, and the choice of a server in the open-loop mode. The same seed and options reproduce the same run. The arrival times depend only on the seed and the rate, not on the queries or the servers, so different query mixes or servers can be compared under the same arrival schedule. Default: a random seed, printed at the start in the open-loop mode.--per-query— Prints statistics for every query at the end: the number of queries and errors, QPS, latency percentiles, the maximum latency and the mean CPU time of a query on the server.-s,--secure— UsingTLSconnection.-t N,--timelimit=N— Time limit in seconds.clickhouse-benchmarkstops sending queries when the specified time limit is reached. Default value: 0 (time limit disabled).--port=N— Server port. Default value: 9000. For the comparison mode you can use multiple--portkeys.--confidence=N— Level of confidence for T-test. Possible values: 0 (80%), 1 (90%), 2 (95%), 3 (98%), 4 (99%), 5 (99.5%). Default value: 5. In the comparison modeclickhouse-benchmarkperforms the Independent two-sample Student’s t-test to determine whether the two distributions aren’t different with the selected level of confidence.--cumulative— Printing cumulative data instead of data per interval.--database=DATABASE_NAME— ClickHouse database name. Default value:default.--user=USERNAME— ClickHouse user name. Default value:default.--password=PSWD— ClickHouse user password. Default value: empty string.--stacktrace— Stack traces output. When the key is set,clickhouse-benchmarkoutputs stack traces of exceptions.--stage=WORD— Query processing stage at server. ClickHouse stops query processing and returns an answer toclickhouse-benchmarkat the specified stage. Possible values:complete,fetch_columns,with_mergeable_state. Default value:complete.--roundrobin— Instead of comparing queries for different--host/--portjust pick one random--host/--portfor every query and send query to it.--reconnect=N— Control reconnection behaviour. Possible values 0 (never reconnect), 1 (reconnect for every query), or N (reconnect after every N queries). Default value: 0.--max-consecutive-errors=N— Number of allowed consecutive errors. Default value: 0.--ignore-error,--continue_on_errors— Continue testing even if queries failed.--client-side-time— Display the time including network communication instead of server-side time; Note that for server versions before 22.8 we always display client-side time.--proto-caps— Enable/disable chunking in data transfer. choices (can be comma-separated):chunked_optional,notchunked,notchunked_optional,send_chunked,send_chunked_optional,send_notchunked,send_notchunked_optional,recv_chunked,recv_chunked_optional,recv_notchunked,recv_notchunked_optional. Default value:notchunked.--help— Shows the help message.--verbose— Increase help message verbosity.
--<session setting name>= SETTING_VALUE. For example, --max_memory_usage=1048576.
Environment variable options
The user name, password and host can be set via environment variablesCLICKHOUSE_USER, CLICKHOUSE_PASSWORD and CLICKHOUSE_HOST.Command line arguments
--user, --password or --host take precedence over environment variables.
Output
By default,clickhouse-benchmark reports for each --delay interval.
Example of the report:
-
Number of queries in the
Queries executed:field. -
Status string containing (in order):
- Endpoint of ClickHouse server.
- Number of processed queries.
- QPS: How many queries the server performed per second during a period specified in the
--delayargument. - RPS: How many rows the server reads per second during a period specified in the
--delayargument. - MiB/s: How many mebibytes the server reads per second during a period specified in the
--delayargument. - result RPS: How many rows placed by the server to the result of a query per second during a period specified in the
--delayargument. - result MiB/s. How many mebibytes placed by the server to the result of a query per second during a period specified in the
--delayargument.
- Percentiles of queries execution time.
Open-loop mode
By defaultclickhouse-benchmark works in a closed loop: each of the --concurrency clients sends the next query when the previous one returns. When the server slows down, it receives fewer queries, so the load adapts to the server.
With --arrival-rate the load does not depend on the server. Queries arrive at random times at a fixed average rate, like requests from many independent users: the time between two arrivals is a random value with the exponential distribution and the mean 1 / R (a Poisson process). Each query is sent at its arrival time even if the previous queries are still running.
At most --max-in-flight queries execute at the same time. An arrival that finds all of them busy waits in a client-side queue until one of them finishes. The latency of a query is measured in the same way as in the closed loop (see --client-side-time), so it does not include the time spent in the queue. The number of queued arrivals is reported separately.
The --iterations option sets the number of arrivals; clickhouse-benchmark waits for all of them to finish. The --timelimit option stops the arrivals after the time limit; the queries in flight finish, and the arrivals in the queue are reported as not sent.
The report contains two more lines, for example:
Arrivals: The number of arrivals.target rate: The rate from--arrival-rate.achieved rate: The number of arrivals divided by the duration of the arrival process. It differs from the target rate by a random error, which is smaller for longer runs.queued: The number of arrivals that found all--max-in-flightslots busy and waited in the client-side queue, and the maximum length of this queue.not sent: The number of arrivals that were still in the queue when the run stopped. It is shown only if it is not zero.In flight: The time-weighted mean and the maximum number of queries executing at the same time.
CPU: The CPU time of the queries on the server per second, in cores.CPU per query: The mean CPU time of a query on the server, in seconds.
--ignore-error), because they also load the server.
The CPU time is the sum of the UserTimeMicroseconds and SystemTimeMicroseconds profile events that the server sends for every query, so it covers the threads executing the query and is an approximation of its total CPU cost. For a distributed query it is summed over all servers the query runs on, because the initiator forwards the profile events of the remote servers. If the server sends no profile events (for example with --send_profile_events=0), the status string shows CPU: not reported by the server.
To run a mixed workload, run several clickhouse-benchmark processes at the same time, one per class of queries. Each process reports the statistics of its own class. Give every process its own --seed, or none: processes with the same seed draw the same random sequence, so their arrivals coincide (or, with different rates, are scaled copies of each other). With independent seeds the combined arrivals of all processes are a Poisson process too.
Examples:
Comparison Mode
clickhouse-benchmark can compare performances for two running ClickHouse servers.
To use the comparison mode, specify endpoints of both servers by two pairs of --host, --port keys. Keys matched together by position in arguments list, the first --host is matched with the first --port and so on. clickhouse-benchmark establishes connections to both servers, then sends queries. Each query addressed to a randomly selected server. The results are shown in a table.