Skip to main content
CockroachDB comes with built-in load generators for simulating different types of client workloads, printing per-operation statistics and totals after a specific duration or max number of operations. To run one of these load generators, use the cockroach workload as described below.
The cockroach workload command is experimental. The interface and output are subject to change.

Synopsis

Create the schema for a workload:
Run a workload:
View help:

Subcommands

CommandUsage
initLoad the schema for the workload. You run this command once for a given schema.
runRun a workload. You can run this command multiple times from different machines to increase concurrency. See Concurrency for more details.

Concurrency

There are two ways to increase the concurrency of a workload:
  • Increase the concurrency of a single workload instance by running cockroach workload run <workload> with the --concurrency flag set to a value higher than the default. Note that not all workloads support this flag.
  • Run multiple instances of a workload in parallel by running cockroach workload run <workload> multiple times from different terminals/machines.

Workloads

WorkloadDescription
bankModels a set of accounts with currency balances.

For this workload, you run workload init to load the schema and then workload run to generate data.
introLoads an intro database, with one table, mytable, with a hidden message.

For this workload, you run only workload init to load the data. The workload run subcommand is not applicable.
kvReads and writes to keys spread (by default, uniformly at random) across the cluster.

For this workload, you run workload init to load the schema and then workload run to generate data.
movrSimulates a workload for the .

For this workload, you run workload init to load the schema and then workload run to generate data.
startrekLoads a startrek database, with two tables, episodes and quotes.

For this workload, you run only workload init to load the data. The workload run subcommand is not applicable.
tpccSimulates a transaction processing workload using a rich schema of multiple tables.

For this workload, you run workload init to load the schema and then workload run to generate data.
ycsbSimulates a high-scale key value workload, either read-heavy, write-heavy, or scan-based, with additional customizations.

For this workload, you run workload init to load the schema and then workload run to generate data.
cockroach workload sets the for its workload queries to the name of the workload that is used. You can filter queries on application_name on the , or in a statement.

Flags

The cockroach workload command does not support connection or security flags like other . Instead, you must use a at the end of the command.

All workloads

All workloads support the following flags:
FlagDescription
--max-conn-lifetimeThe maximum duration of a connection. Default: 300s
--max-conn-lifetime-jitterThe maximum jitter when tearing down a connection. Default: 30s
--max-conn-idle-timeThe maximum idle time for a connection. Default: 150s
--conn-healthcheck-periodThe connection health check interval. Default: 30s
--min-connsThe minimum number of connections in the connection pool. Default: 0

bank workload

FlagDescription
--concurrencyThe number of concurrent workers.

Applicable commands: init or run
Default: 2 * number of CPUs
--dbThe SQL database to use.

Applicable commands: init or run
Default: bank
--display-everyThe frequency for printing per-operation statistics. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1s
--display-formatThe format for printing per-operation statistics (simple, incremental-json). When using incremental-json, note that totals are not printed at the end of the workload’s duration.

Applicable command: run
Default: simple
--dropDrop the existing database, if it exists.

Applicable commands: init or run. For the run command, this flag must be used in conjunction with --init.
--durationThe duration to run, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable commands: init or run
Default: 0, which means run forever.
--histogramsThe file to write per-op incremental and cumulative histogram data to.

Applicable command: run
--initDeprecated. Use the init command instead.

Applicable command: run
--max-opsThe maximum number of operations to run.

Applicable command: run
--max-rateThe maximum frequency of operations (reads/writes).

Applicable command: run
Default: 0, which means unlimited.
--payload-bytesThe size of the payload field in each initial row.

Applicable commands: init or run
Default: 100
--rampThe duration over which to ramp up load.

Applicable command: run
--rangesThe initial number of ranges in the bank table.

Applicable commands: init or run
Default: 10
--rowsThe initial number of accounts in the bank table.

Applicable commands: init or run
Default: 1000
--seedThe key hash seed.

Applicable commands: init or run
Default: A random seed is used each time the command is run. Reusing a seed is recommended only for reproducing a specific pattern or behavior. Workloads that have a random element should use the default random seed.
--tolerate-errorsKeep running on error.

Applicable command: run

intro and startrek workloads

These workloads generate data but do not offer the ability to run continuous load. Thus, only the init subcommand is supported.
FlagDescription
--dropDrop the existing database, if it exists, before loading the dataset.

kv workload

FlagDescription
--batchThe number of blocks to insert in a single SQL statement.

Applicable commands: init or run
Default: 1
--concurrencyThe number of concurrent workers.

Applicable commands: init or run
Default: 8 --cycle-length
The number of keys repeatedly accessed by each writer.Applicable commands: init or run
Default: 9223372036854775807
--dbThe SQL database to use.

Applicable commands: init or run
Default: kv
--display-everyThe frequency for printing per-operation statistics. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1s
--display-formatThe format for printing per-operation statistics (simple, incremental-json). When using incremental-json, note that totals are not printed at the end of the workload’s duration.

Applicable command: run
Default: simple
--dropDrop the existing database, if it exists.

Applicable commands: init or run
--durationThe duration to run, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 0, which means run forever.
--histogramsThe file to write per-op incremental and cumulative histogram data to.

Applicable command: run
--initDeprecated. Use the init command instead.

Applicable command: run
--max-block-bytesThe maximum amount of raw data written with each insertion.

Applicable commands: init or run
Default: 2
--max-opsThe maximum number of operations to run.

Applicable command: run
--max-rateThe maximum frequency of operations (reads/writes).

Applicable command: run
Default: 0, which means unlimited.
--min-block-bytesThe minimum amount of raw data written with each insertion.

Applicable commands: init or run
Default: 1
--rampThe duration over which to ramp up load.

Applicable command: run
--read-percentThe percent (0-100) of operations that are reads of existing keys.

Applicable commands: init or run
--seedThe key hash seed.

Applicable commands: init or run
Default: A random seed is used each time the command is run. Reusing a seed is recommended only for reproducing a specific pattern or behavior. Workloads that have a random element should use the default random seed.
--sequentialPick keys sequentially instead of randomly.

Applicable commands: init or run
--splitsThe number of splits to perform before starting normal operations.

Applicable commands: init or run
--tolerate-errorsKeep running on error.

Applicable command: run
--use-optUse .

Applicable commands: init or run
Default: true
--write-seqInitial write sequence value.

Applicable commands: init or run

movr workload

FlagDescription
--data-loaderHow to load initial table data. Valid options are INSERT and IMPORT.

Applicable commands: init or run
Default: INSERT
--dbThe SQL database to use.

Applicable commands: init or run
Default: movr
--display-everyThe frequency for printing per-operation statistics. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1s
--display-formatThe format for printing per-operation statistics (simple, incremental-json). When using incremental-json, note that totals are not printed at the end of the workload’s duration.

Applicable command: run
Default: simple
--dropDrop the existing database, if it exists.

Applicable commands: init or run
--durationThe duration to run, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 0, which means run forever.
--histogramsThe file to write per-op incremental and cumulative histogram data to.

Applicable command: run
--histograms-max-latencyExpected maximum latency of running a query, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1m40s
--max-opsThe maximum number of operations to run.

Applicable command: run
--max-rateThe maximum frequency of operations (reads/writes).

Applicable command: run
Default: 0, which means unlimited.
--methodThe SQL issue method (prepare, noprepare, simple).

Applicable commands: init or run
Default: prepare
--num-historiesThe initial number of ride location histories.

Applicable commands: init or run
Default: 1000
--num-promo-codesThe initial number of promo codes.

Applicable commands: init or run
Default: 1000
--num-ridesInitial number of rides.

Applicable commands: init or run
Default: 500
--num-usersInitial number of users.

Applicable commands: init or run
Default: 50
--num-vehiclesInitial number of vehicles.

Applicable commands: init or run
Default: 15
--rampThe duration over which to ramp up load.

Applicable command: run
--seedThe random number generator seed.

Applicable commands: init or run
Default: A random seed is used each time the command is run. Reusing a seed is recommended only for reproducing a specific pattern or behavior. Workloads that have a random element should use the default random seed.
--tolerate-errorsKeep running on error.

Applicable command: run

tpcc workload

FlagDescription
--active-warehousesRun the load generator against a specific number of warehouses.

Applicable commands: init or run
Defaults: Value of --warehouses
--concurrencyThe number of concurrent workers.

Applicable commands: init or run
Default: 16
--data-loaderHow to load initial table data. Valid options are INSERT and IMPORT.

Applicable commands: init or run
Default: INSERT
--dbThe SQL database to use.

Applicable commands: init or run
Default: tpcc
--display-everyThe frequency for printing per-operation statistics. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1s
--display-formatThe format for printing per-operation statistics (simple, incremental-json). When using incremental-json, note that totals are not printed at the end of the workload’s duration.

Applicable command: run
Default: simple
--dropDrop the existing database, if it exists.

Applicable commands: init or run. For the run command, this flag must be used in conjunction with --init.
--durationThe duration to run, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 0, which means run forever.
--fksAdd foreign keys.

Applicable commands: init or run
Default: true
--histogramsThe file to write per-op incremental and cumulative histogram data to.

Applicable command: run
--idle-connsTests the TPCC workload with idle connections.
--initDeprecated. Use the init command instead.

Applicable command: run
--max-opsThe maximum number of operations to run.

Applicable command: run
--max-rateThe maximum frequency of operations (reads/writes).

Applicable command: run
Default: 0, which means unlimited.
--mixWeights for the transaction mix.

Applicable commands: init or run
Default: newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1, which matches the TPC-C specification.
--partition-affinityRun the load generator against a specific partition. This flag must be used in conjunction with --partitions.

Applicable commands: init or run
Default: -1
--partitionsPartition tables. This flag must be used in conjunction with --split.

Applicable commands: init or run
--rampThe duration over which to ramp up load.

Applicable command: run
--scatterScatter ranges.

Applicable commands: init or run
--seedThe random number generator seed.

Applicable commands: init or run
Default: A random seed is used each time the command is run. Reusing a seed is recommended only for reproducing a specific pattern or behavior. Workloads that have a random element should use the default random seed.
--serializableForce serializable mode. CockroachDB only supports SERIALIZABLE isolation, so this flag is not necessary.

Applicable command: init
--split.

Applicable commands: init or run
--tolerate-errorsKeep running on error.

Applicable command: run
--waitRun in wait mode, i.e., include think/keying sleeps.

Applicable commands: init or run
Default: true
--warehousesThe number of warehouses for loading initial data, at approximately 200 MB per warehouse.

Applicable commands: init or run
Default: 1
--workersThe number of concurrent workers.

Applicable commands: init or run
Default: --warehouses * 10
--zonesThe number of for partitioning. This number should match the number of --partitions and the zones used to start the cluster.

Applicable command: init

ycsb workload

FlagDescription
--concurrencyThe number of concurrent workers.

Applicable commands: init or run
Default: 8
--data-loaderHow to load initial table data. Valid options are INSERT and IMPORT.

Applicable commands: init or run
Default: INSERT
--dbThe SQL database to use.

Applicable commands: init or run
Default: ycsb
--display-everyThe frequency for printing per-operation statistics. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 1s
--display-formatThe format for printing per-operation statistics (simple, incremental-json). When using incremental-json, note that totals are not printed at the end of the workload’s duration.

Applicable command: run
Default: simple
--dropDrop the existing database, if it exists.

Applicable commands: init or run. For the run command, this flag must be used in conjunction with --init.
--durationThe duration to run, with a required time unit suffix. Valid time units are ns, us, ms, s, m, and h.

Applicable command: run
Default: 0, which means run forever.
--familiesPlace each column in its own .

Applicable commands: init or run
--histogramsThe file to write per-op incremental and cumulative histogram data to.

Applicable command: run
--initDeprecated. Use the init command instead.

Applicable command: run
--insert-countNumber of rows to sequentially insert before beginning random number generation.

Applicable commands: init or run
Default: 10000
--jsonUse JSONB rather than relational data.

Applicable commands: init or run
--max-opsThe maximum number of operations to run.

Applicable command: run
--max-rateThe maximum frequency of operations (reads/writes).

Applicable command: run
Default: 0, which means unlimited.
--methodThe SQL issue method (prepare, noprepare, simple).

Applicable commands: init or run
Default: prepare
--rampThe duration over which to ramp up load.

Applicable command: run
--request-distributionDistribution for the random number generator (zipfian, uniform).

Applicable commands: init or run.
Default: zipfian
--seedThe random number generator seed.

Applicable commands: init or run
Default: A random seed is used each time the command is run. Reusing a seed is recommended only for reproducing a specific pattern or behavior. Workloads that have a random element should use the default random seed.
--splitsNumber of to perform before starting normal operations.

Applicable commands: init or run
--tolerate-errorsKeep running on error.

Applicable command: run
--workloadThe type of workload to run (A, B, C, D, or F). For details about these workloads, see YCSB Workloads.

Applicable commands: init or run
Default: B

Logging

By default, the cockroach workload command logs messages to stderr. This includes events with INFO and higher. If you need to troubleshoot this command’s behavior, you can .

Examples

These examples assume that you have already :

Run the bank workload

  1. Load the initial schema:
  2. Run the workload for 1 minute:
    You’ll see per-operation statistics print to standard output every second:
    After the specified duration (1 minute in this case), the workload will stop and you’ll see totals printed to standard output:

Run the kv workload

  1. Load the initial schema:
  2. Run the workload for 1 minute:
    You’ll see per-operation statistics print to standard output every second:
    After the specified duration (1 minute in this case), the workload will stop and you’ll see totals printed to standard output:

Load the intro dataset

  1. Load the dataset:
  2. Launch the built-in SQL client to view it:

Load the startrek dataset

  1. Load the dataset:
  2. Launch the built-in SQL client to view it:

Load the movr dataset

  1. Load the dataset:
  2. Launch the built-in SQL client to view it:
+----------------------------+ promo_codes rides user_promo_codes users vehicle_location_histories vehicles (6 rows)

Run the movr workload

  1. Load the initial schema:
  2. Initialize and run the workload for 1 minute:
    You’ll see per-operation statistics print to standard output every second:
    After the specified duration (1 minute in this case), the workload will stop and you’ll see totals printed to standard output:

Run the tpcc workload

  1. Load the initial schema and data:
  2. Run the workload for 10 minutes:
    You’ll see per-operation statistics print to standard output every second:
    After the specified duration (10 minutes in this case), the workload will stop and you’ll see totals printed to standard output:

Run the ycsb workload

  1. Load the initial schema and data:
  2. Run the workload for 10 minutes:
    You’ll see per-operation statistics print to standard output every second:
    After the specified duration (10 minutes in this case), the workload will stop and you’ll see totals printed to standard output:

Customize the frequency and format of per-operation statistics

To customize the frequency of per-operation statistics, use the --display-every flag, with ns, us, ms, s, m, and h as valid time units. To customize the format of per-operation statistics, use the --display-format flag, with incremental-json or simple (default) as options.
  1. Load the initial schema and data:
  2. Run the workload for 1 minute, printing the output every 5 seconds as JSON:
    When using incremental-json, note that totals are not printed at the end of the workload’s duration.

See also