Performance Benchmarking with TPC-C


This lab walks you through TPC-C performance benchmarking on CockroachDB. It measures tpmC (new order transactions/minute) on a TPC-C dataset of 10 warehouses (for a total dataset size of 2GB) on 3 nodes.

{{}} For training purposes, the dataset used in this lab is small. For instructions on how to benchmark with a larger dataset, see Performance Benchmarking with TPC-C. {{}}

Before you begin

In this lab, you'll start with a fresh cluster, so make sure you've stopped and cleaned up the cluster from the previous labs.

Step 1. Start a 3-node cluster

Start and initialize a cluster like you did in previous modules.

{{}} To simplify the process of running multiple nodes on your local computer, you'll start them in the background instead of in separate terminals. {{}}

  1. In a new terminal, start node 1:

    $ ./cockroach start \
    --insecure \
    --store=node1 \
    --listen-addr=localhost:26257 \
    --http-addr=localhost:8080 \
    --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \
  2. Perform a one-time initialization of the cluster:

    $ ./cockroach init --insecure --host=localhost:26257
  3. Start node 2:

    $ ./cockroach start \
    --insecure \
    --store=node2 \
    --listen-addr=localhost:26258 \
    --http-addr=localhost:8081 \
    --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \
  4. Start node 3:

    $ ./cockroach start \
    --insecure \
    --store=node3 \
    --listen-addr=localhost:26259 \
    --http-addr=localhost:8082 \
    --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \
  5. Start node 4, which will be used to run the TPC-C benchmark:

    $ ./cockroach start \
    --insecure \
    --store=node4 \
    --listen-addr=localhost:26260 \
    --http-addr=localhost:8083 \
    --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \

{{}} This configuration is intended for training and performance benchmarking only. For production deployments, there are other important considerations, such as ensuring that data is balanced across at least three availability zones for resiliency. See the Production Checklist for more details. {{}}

Step 3. Load data for the benchmark

CockroachDB comes with built-in load generators for simulating different types of client workloads, printing out per-operation statistics every second and totals after a specific duration or max number of operations. This step features CockroachDB's version of the TPC-C workload.

On the fourth node, use cockroach workload to load the initial schema and data:

$ ./cockroach workload init tpcc \
--warehouses=10 \

This will take about ten minutes to load.

{{}} For more tpcc options, use workload run tpcc --help. For details about other load generators included in workload, use workload run --help. {{}}

Step 4. Run the benchmark

Run the workload for ten "warehouses" of data for five minutes (300 seconds):

$ ./cockroach workload run tpcc \
--warehouses=10 \
--ramp=30s \
--duration=300s \
--split \
--scatter \

Step 5. Interpret the results

Once the workload has finished running, you should see a final output line:

  300.0s      120.8  93.9%     52.9     48.2     75.5     96.5    134.2    243.3

You will also see some audit checks and latency statistics for each individual query. For this run, some of those checks might indicate that they were SKIPPED due to insufficient data. For a more comprehensive test, run workload for a longer duration (e.g., two hours). The tpmC (new order transactions/minute) number is the headline number and efc ("efficiency") tells you how close CockroachDB gets to theoretical maximum tpmC.

The TPC-C specification has p90 latency requirements in the order of seconds, but as you see here, CockroachDB far surpasses that requirement with p90 latencies in the hundreds of milliseconds.

Step 6. Clean up

In the next module, you'll start with a fresh cluster, so take a moment to clean things up.

  1. Exit the SQL shell:

    > \q
  2. Stop all CockroachDB nodes:

    $ pkill -9 cockroach

    This simplified shutdown process is only appropriate for a lab/evaluation scenario.

  3. Remove the nodes' data directories:

    $ rm -rf node1 node2 node3 node4

What's next?

Data Import