sysbench is the standard benchmarking tool for MySQL performance testing. It simulates OLTP workloads and helps validate configuration changes, hardware upgrades, and tuning decisions.
Installation
# Ubuntu/Debian
apt-get install sysbench
# macOS
brew install sysbenchPrepare Test Data
sysbench oltp_read_write \
--mysql-host=localhost \
--mysql-user=root \
--mysql-password=secret \
--mysql-db=sysbench_test \
--tables=10 \
--table-size=1000000 \
prepareRun Read/Write Benchmark
sysbench oltp_read_write \
--mysql-host=localhost \
--mysql-user=root \
--mysql-password=secret \
--mysql-db=sysbench_test \
--tables=10 \
--table-size=1000000 \
--threads=16 \
--time=120 \
--report-interval=10 \
runRead Key Metrics
SQL statistics:
queries performed:
read: 2,847,291
write: 812,083
other: 162,416
total: 3,821,790
transactions: 190,623 (1588.52 per sec.)
queries: 3,821,790 (31861.55 per sec.)
Latency (ms):
min: 4.92
avg: 10.07
max: 143.21
95th percentile: 19.65Available Test Suites
sysbench oltp_read_only # read-only SELECT workload
sysbench oltp_write_only # insert/update/delete only
sysbench oltp_read_write # mixed workload (default OLTP)
sysbench oltp_point_select # primary key lookups
sysbench oltp_update_index # indexed UPDATE workload
sysbench fileio # disk I/O benchmark
sysbench memory # memory throughputCleanup
sysbench oltp_read_write \
--mysql-host=localhost --mysql-user=root --mysql-password=secret \
--mysql-db=sysbench_test --tables=10 \
cleanupKey Takeaways
- Use
--table-size=1000000or larger to ensure data exceeds the buffer pool - Run for at least 120 seconds to get past the warm-up period
- Focus on 95th percentile latency, not just average — it reflects real user experience
- Use
oltp_read_onlyto isolate read performance from write contention
JusDB Can Help
Benchmarking MySQL before and after changes is the only way to know if you improved things. JusDB can design and run benchmarks that reflect your actual production workload.