LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

sysbench

Multi-threaded system benchmark tool

TLDR

CPU benchmark
$ sysbench cpu run
copy
CPU benchmark with threads
$ sysbench cpu --threads=[4] run
copy
Memory benchmark
$ sysbench memory run
copy
File I/O prepare
$ sysbench fileio --file-total-size=[10G] prepare
copy
File I/O benchmark
$ sysbench fileio --file-total-size=[10G] --file-test-mode=[rndrw] run
copy
MySQL benchmark
$ sysbench oltp_read_write --mysql-host=[localhost] --mysql-user=[user] --mysql-password=[pass] --mysql-db=[test] run
copy
Cleanup test files
$ sysbench fileio --file-total-size=[10G] cleanup
copy
CPU benchmark with custom prime limit
$ sysbench cpu --cpu-max-prime=[20000] --threads=[4] run
copy

SYNOPSIS

sysbench test [options] [prepare|run|cleanup]

DESCRIPTION

sysbench is a multi-threaded benchmarking tool for evaluating system performance across CPU, memory, file I/O, and database workloads. It provides consistent, reproducible measurements that allow meaningful comparisons between different hardware configurations, kernel versions, or tuning parameters.The tool includes built-in test types for common benchmarks. CPU tests stress processors using prime number calculations to measure computational throughput. Memory tests measure bandwidth and latency across sequential and random access patterns. File I/O tests support multiple modes including sequential writes, sequential reads, and random read/write mixes, requiring a preparation step to create test files before running and a cleanup step afterward.Database benchmarks simulate OLTP (Online Transaction Processing) workloads against MySQL or PostgreSQL, executing realistic mixes of select, insert, update, and delete queries. All test types support multi-threaded execution to measure how performance scales with parallelism, revealing bottlenecks and contention points. Custom Lua scripts can define additional workloads beyond the built-in tests.

PARAMETERS

cpu

CPU test.
memory
Memory test.
fileio
File I/O test.
oltp_read_write
Database OLTP test.
oltp_read_only
Read-only database test.
threads
Thread scheduler performance test.
mutex
Mutex contention performance test.
--threads N
Number of threads (default: 1).
--time SECONDS
Test duration (default: 10).
--events N
Maximum number of events (default: 0, unlimited).
--file-total-size SIZE
Total file size.
--file-test-mode MODE
I/O mode (seqwr, seqrd, rndrw, etc.).
--mysql-host HOST
MySQL host.
--mysql-user USER
MySQL user.
--mysql-password PASS
MySQL password.
--mysql-db DB
MySQL database name.
--cpu-max-prime N
Upper limit for prime number calculation in CPU test (default: 10000).
--memory-block-size SIZE
Size of memory block for memory test (default: 1K).
--memory-total-size SIZE
Total size of data to transfer in memory test (default: 100G).
--memory-oper OP
Memory operation type: read or write (default: write).
--memory-access-mode MODE
Memory access mode: seq or rnd (default: seq).
--file-num N
Number of files to create (default: 128).
--file-extra-flags FLAGS
Additional flags for opening files: sync, dsync, direct.
--percentile N
Percentile to calculate in latency statistics (default: 95).
--report-interval SECONDS
Periodically report intermediate statistics (0 = disabled).
prepare
Prepare test data (required for fileio and database tests).
run
Run the benchmark test.
cleanup
Clean up test data created during prepare.

CAVEATS

Results depend on test parameters. Synthetic benchmarks don't reflect all workloads. File tests need disk space. Database tests need setup.

HISTORY

sysbench was created by Alexey Kopytov at MySQL AB around 2004. It became a standard tool for MySQL benchmarking and general system performance testing.

SEE ALSO

fio(1), stress-ng(1), pgbench(1), iperf(1)

Copied to clipboard
Kai