Run a Sysbench stress test against an ApsaraDB RDS for PostgreSQL instance to measure Online Transaction Processing (OLTP) performance. The test uses the OLTP combined read-write workload and consists of three phases: load test data, run the stress test, then clean up.
Prerequisites
Before you begin, ensure that you have:
An ApsaraDB RDS for PostgreSQL instance with a database named
sbtestSysbench installed on your client machine
The instance endpoint, port, username, and password
Run the stress test
Each phase uses --time=180, so each phase runs for 180 seconds.
Step 1: Load test data
Load the test dataset using 20 concurrent threads.
sysbench ./tests/include/oltp_legacy/oltp.lua \
--db-driver=pgsql \
--pgsql-db=sbtest \
--pgsql-user=<username> \
--pgsql-password=<password> \
--pgsql-port=5432 \
--pgsql-host=<host> \
--oltp-tables-count=64 \
--oltp-table-size=10000000 \
--time=180 \
--max-requests=0 \
--threads=20 \
--report-interval=5 \
--forced-shutdown=1 \
prepareStep 2: Run the stress test
Run the OLTP combined read-write workload using 64 concurrent threads.
sysbench ./tests/include/oltp_legacy/oltp.lua \
--db-driver=pgsql \
--pgsql-db=sbtest \
--pgsql-user=<username> \
--pgsql-password=<password> \
--pgsql-port=5432 \
--pgsql-host=<host> \
--oltp-tables-count=64 \
--oltp-table-size=10000000 \
--time=180 \
--max-requests=0 \
--threads=64 \
--report-interval=5 \
--forced-shutdown=1 \
runStep 3: Clean up test data
Remove the test dataset using 200 concurrent threads.
sysbench ./tests/include/oltp_legacy/oltp.lua \
--db-driver=pgsql \
--pgsql-db=sbtest \
--pgsql-user=<username> \
--pgsql-password=<password> \
--pgsql-port=5432 \
--pgsql-host=<host> \
--oltp-tables-count=64 \
--oltp-table-size=10000000 \
--time=180 \
--max-requests=0 \
--threads=200 \
--report-interval=5 \
--forced-shutdown=1 \
cleanupSysbench parameter reference
Replace the placeholders in the commands with your instance values before running.
| Parameter | Description | Value |
|---|---|---|
--pgsql-host | Internal endpoint of the RDS instance | <host> |
--pgsql-port | Port of the RDS instance | 5432 |
--pgsql-user | Database username | <username> |
--pgsql-password | Password for the database user | <password> |
--pgsql-db | Target database name | sbtest |
--oltp-tables-count | Number of test tables | 64 |
--oltp-table-size | Number of rows per table | 10000000 |
--threads | Number of concurrent threads (varies by phase) | 20 (prepare) / 64 (run) / 200 (cleanup) |
--time | Duration of each phase in seconds | 180 |
--max-requests | Maximum number of requests; 0 means unlimited | 0 |
--report-interval | Progress report interval in seconds | 5 |
--forced-shutdown | Force shutdown after --time expires; 1 means enabled | 1 |