A toolbox to benchmark workloads in TPC for TiDB and almost MySQL compatible databases, and PostgreSQL compatible database, such as PostgreSQL / CockroachDB / AlloyDB / Yugabyte.
You can use one of the three approaches
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/pingcap/go-tpc/master/install.sh | shAnd then open a new terminal to try go-tpc
You can download the pre-built binary here and then gunzip it
git clone https://github.com/pingcap/go-tpc.git
cd go-tpc
make buildThen you can find the go-tpc binary file in the ./bin directory.
If you have go-tpc in your PATH, the command below you should replace ./bin/go-tpc with go-tpc
By default, go-tpc uses root::@tcp(127.0.0.1:4000)/test as the default dsn address, you can override it by setting below flags:
-D, --db string Database name (default "test")
-H, --host string Database host (default "127.0.0.1")
-p, --password string Database password (defaults to GO_TPC_PASSWORD when not explicitly set)
-P, --port int Database port (default 4000)
-U, --user string Database user (default "root")
Note:
When exporting csv files to a directory,
go-tpcwill also create the necessary tables for further data input if the provided database address is accessible.
For example:
./bin/go-tpc -H 127.0.0.1 -P 3306 -D tpcc ...Set GO_TPC_PASSWORD to supply a password without including it in the process command line. For example, in Bash:
read -r -s -p 'Database password: ' GO_TPC_PASSWORD
printf '\n'
export GO_TPC_PASSWORD
./bin/go-tpc tpcc --warehouses 4 run
unset GO_TPC_PASSWORDAn explicitly supplied -p / --password takes precedence, including an empty value. Otherwise, go-tpc uses GO_TPC_PASSWORD. Environment variables keep passwords out of argv, but processes with sufficient OS permissions can still read them.
For MySQL and TiDB, the default is tls=preferred, matching the MySQL client's --ssl-mode=PREFERRED: use TLS when the server supports it, without verifying its certificate, and fall back to an unencrypted connection otherwise. This preserves compatibility with local TiDB installations that do not enable TLS. Use certificate verification when connecting over an untrusted network:
# Verify the server certificate and hostname using a CA file.
./bin/go-tpc tpcc run -H db.example.com --ssl-ca /path/to/ca.pem
# Verify using system root certificates.
./bin/go-tpc tpcc run -H db.example.com --conn-params tls=truePostgreSQL TLS is configured through --conn-params; the --ssl-* flags apply only to MySQL. The bundled lib/pq driver's default sslmode=require requires encryption but does not verify the server hostname. Use verify-full to verify the server certificate and hostname:
./bin/go-tpc tpcc prepare -d postgres -U myuser -D test -H db.example.com -P 5432 --conn-params 'sslmode=verify-full&sslrootcert=/path/to/ca.pem'The PostgreSQL examples below use sslmode=disable only for local databases without TLS. For connections over an untrusted network, use the verify-full parameters above. The examples can also omit -p when using GO_TPC_PASSWORD.
# Create 4 warehouses with 4 threads
./bin/go-tpc tpcc --warehouses 4 prepare -T 4./bin/go-tpc tpcc prepare -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable
# Run TPCC workloads, you can just run or add --wait option to including wait times
./bin/go-tpc tpcc --warehouses 4 run -T 4
# Run TPCC including wait times(keying & thinking time) on every transactions
./bin/go-tpc tpcc --warehouses 4 run -T 4 --wait./bin/go-tpc tpcc run -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable
# Check consistency. you can check after prepare or after run
./bin/go-tpc tpcc --warehouses 4 check# Cleanup
./bin/go-tpc tpcc --warehouses 4 cleanup# Generate csv files (split to 100 files each table)
./bin/go-tpc tpcc --warehouses 4 prepare -T 100 --output-type csv --output-dir data
# Specified tables when generating csv files
./bin/go-tpc tpcc --warehouses 4 prepare -T 100 --output-type csv --output-dir data --tables history,orders
# Start pprof
./bin/go-tpc tpcc --warehouses 4 prepare --output-type csv --output-dir data --pprof 127.0.0.1:10111The TPC-C --pprof and --metrics-addr endpoints are disabled unless explicitly configured, and have no authentication or TLS. Bind them to a loopback address such as 127.0.0.1:10111 (pprof) or 127.0.0.1:10112 (metrics) for local access. If remote monitoring requires a public or wildcard bind such as :10112, restrict access with firewall rules or a trusted network. go-tpc warns when an endpoint is bound beyond loopback. The pprof command-line endpoint /debug/pprof/cmdline is disabled by default to avoid exposing command-line secrets such as -p; CPU, heap, goroutine, and other runtime profiles remain available. Pass --pprof-enable-cmdline to opt in if a caller requires /debug/pprof/cmdline (prefer GO_TPC_PASSWORD and restrict access when enabling it).
If you want to import tpcc data into TiDB, please refer to import-to-tidb.
# Prepare data with scale factor 1
./bin/go-tpc tpch --sf=1 prepare
# Prepare data with scale factor 1, create tiflash replica, and analyze table after data loaded
./bin/go-tpc tpch --sf 1 --analyze --tiflash-replica 1 prepare./bin/go-tpc tpch prepare -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable
# Run TPCH workloads with result checking
./bin/go-tpc tpch --sf=1 --check=true run
# Run TPCH workloads without result checking
./bin/go-tpc tpch --sf=1 run./bin/go-tpc tpch run -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable
# Cleanup
./bin/go-tpc tpch cleanup-
First please refer to the above instruction(
go-tpc tpcc --warehouses $warehouses prepare) to prepare the TP part schema and populate data -
Then uses
go-tpc ch prepareto prepare the AP part schema and data
A detail example to run CH workload on TiDB can be refered to TiDB Doc
# Prepare TP data
./bin/go-tpc tpcc --warehouses 10 prepare -T 4 -D test -H 127.0.0.1 -P 4000
# Prepare AP data, create tiflash replica, and analyze table after data loaded
./bin/go-tpc ch --analyze --tiflash-replica 1 prepare -D test -H 127.0.0.1 -P 4000# Prepare TP data
./bin/go-tpc tpcc prepare -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable -T 4
# Prepare AP data
./bin/go-tpc ch prepare -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable./bin/go-tpc ch --warehouses $warehouses -T $tpWorkers -t $apWorkers --time $measurement-time run./bin/go-tpc ch run -d postgres -U myuser -p '12345678' -D test -H 127.0.0.1 -P 5432 --conn-params sslmode=disable
rawsql command is used to execute sql from given sql files.
./bin/go-tpc rawsql run --query-files $path-to-query-files