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.
In a new terminal, start node 1:copy
$ cockroach start \ --insecure \ --store=node1 \ --listen-addr=localhost:26257 \ --http-addr=localhost:8080 \ --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \ --background
Perform a one-time initialization of the cluster:copy
$ cockroach init --insecure --host=localhost:26257
Start node 2:copy
$ cockroach start \ --insecure \ --store=node2 \ --listen-addr=localhost:26258 \ --http-addr=localhost:8081 \ --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \ --background
Start node 3:copy
$ cockroach start \ --insecure \ --store=node3 \ --listen-addr=localhost:26259 \ --http-addr=localhost:8082 \ --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \ --background
Start node 4, which will be used to run the TPC-C benchmark:copy
$ cockroach start \ --insecure \ --store=node4 \ --listen-addr=localhost:26260 \ --http-addr=localhost:8083 \ --join=localhost:26257,localhost:26258,localhost:26259,localhost:26260 \ --background
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 \ 'postgresql://root@localhost:26260?sslmode=disable'
This will take about ten minutes to load.
tpcc options, use
workload run tpcc --help. For details about other load generators included in
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 \ 'postgresql://root@localhost:26260?sslmode=disable'
Step 5. Interpret the results
workload has finished running, you should see a final output line:
_elapsed_______tpmC____efc__avg(ms)__p50(ms)__p90(ms)__p95(ms)__p99(ms)_pMax(ms) 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
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.
Exit the SQL shell:copy
Stop all CockroachDB nodes:copy
$ pkill -9 cockroach
This simplified shutdown process is only appropriate for a lab/evaluation scenario.
Remove the nodes' data directories:copy
$ rm -rf node1 node2 node3 node4