sysbench is a popular tool for benchmarking databases like PostgreSQL and MySQL, as well as system capabilities like CPU, memory, and I/O. The YugabyteDB version of sysbench is forked from the official version with a few modifications to better reflect YugabyteDB's distributed nature.

Running the benchmark

Prerequisites

To ensure the recommended hardware requirements are met and the database is correctly configured before benchmarking, review the deployment checklist.

Make sure you have the YSQL shell ysqlsh exported to the PATH variable.

$ export PATH=$PATH:/path/to/ysqlsh

Install sysbench

Install sysbench on a machine which satisfies the Prerequisites using one of the following options:

Install sysbench using the following steps:

$ cd $HOME
$ git clone https://github.com/yugabyte/sysbench.git
$ cd sysbench
$ ./autogen.sh && ./configure --with-pgsql && make -j && sudo make install

Note

RHEL package is only for EL8
wget https://github.com/yugabyte/sysbench/releases/download/1.0.0-yb/sysbench-1.0.0-1.el8.x86_64.rpm

sudo yum install -y sysbench-1.0.0-1.el8.x86_64.rpm 

Note

The MacOS package is only for Apple Silicon.
brew install postgresql@14 wget

wget https://github.com/yugabyte/sysbench/releases/download/1.0.0-yb/Sysbench.pkg

sudo  installer -pkg Sysbench.pkg -target /

This installs the sysbench utility in /usr/local/bin.

Start YugabyteDB

Start your YugabyteDB cluster by following the steps in Manual deployment.

Tip
You will need the IP addresses of the nodes in the cluster for the next step.

Run individual workloads

You can choose to run the following workloads individually:

  • oltp_read_only
  • oltp_read_write
  • oltp_multi_insert
  • oltp_update_index
  • oltp_update_non_index
  • oltp_delete

Before starting the workload, load the data as follows:

sysbench <workload> \
  --pgsql-host=<comma-separated-ips> \
  --tables=20 \
  --table_size=5000000 \
  --range_key_partitioning=false \
  --serial_cache_size=1000 \
  --create_secondary=true \
  --pgsql-db=yugabyte \
  --pgsql-user=yugabyte \
  --db-driver=pgsql \
  --pgsql-port=5433 \
  prepare

Run a workload as follows:

sysbench <workload> \
  --pgsql-host=<comma-separated-ips> \
  --tables=20 \
  --table_size=5000000  \
  --range_key_partitioning=false \
  --serial_cache_size=1000 \
  --create_secondary=true \
  --pgsql-db=yugabyte \
  --pgsql-user=yugabyte \
  --db-driver=pgsql \
  --pgsql-port=5433 \
  --time=1800 \
  --warmup-time=300 \
  --num_rows_in_insert=10 \
  --point_selects=10 \
  --index_updates=10 \
  --non_index_updates=10 \
  --range_selects=false \
  --thread-init-timeout=90 \
  --threads=60 \
  run

Expected results

The following results are for a 3-node cluster running YBDB version 2.25.0, with each node running on a c5.2xlarge AWS instance (8 cores, 16 GiB of RAM), all in the same AZ, with a replication factor of 3 and TLS enabled.

10 tables each with 100k rows

Workload Benchmark Statistics Per Query Statistics Queries executed in each transaction
Throughput (txns/sec) Latency (ms) - avg Throughput (queries/sec) Latency (ms) - avg
oltp_read_only 4616.32 13 46163.2 1.3 10 point selects
oltp_read_write 245.49 97.76 7855.68 3.05 10 point selects
10 index updates
10 non-index update
1 Insert
1 Delete
oltp_multi_insert 585.66 40.98 5856.6 4.09 10 Insert
oltp_update_index 259.64 92.43 2596.4 9.43 10 index updates

The Queries executed in each transaction column shows the individual queries that are executed as part of each sysbench transaction, for each workload. These queries impact the overall transaction performance and are key to understanding the workload distribution for different sysbench benchmarks.