gitmyhub

sysbench

C ★ 6.8k updated 1y ago

Scriptable database and system performance benchmark

A command-line tool for benchmarking databases and system hardware, CPU, memory, file I/O, and database queries, used by engineers to compare configurations or stress-test servers before production.

CLuaMySQLPostgreSQLsetup: moderatecomplexity 2/5

sysbench is a command-line tool for measuring how fast a computer system or database can work under load. Engineers and developers use it to run standardized tests against MySQL, PostgreSQL, or other databases, and to benchmark CPU speed, memory throughput, file system performance, and threading. The project has around 6,700 GitHub stars and is written mostly in C.

The tool comes with several built-in tests you can run right away. The OLTP group of tests simulates typical database read and write operations, which is useful for comparing database setups or configurations. Separate tests cover raw CPU math, memory access patterns, file I/O, thread scheduling, and lock contention. Because each test is defined as a Lua script, you can also write your own custom benchmarks if the built-in ones do not match your scenario.

Installing sysbench on Linux is straightforward: the maintainers publish ready-made packages for Debian, Ubuntu, RHEL, CentOS, Fedora, and Arch Linux via a package repository. On macOS, Homebrew provides an up-to-date package. Native Windows builds were dropped starting with version 1.0; the recommended approach on Windows is to use Windows Subsystem for Linux and then follow the Linux instructions.

Building from source requires a C compiler, automake, libtool, and optionally the client libraries for MySQL or PostgreSQL if you want database support. The build process is a standard configure-then-make sequence. Once installed, you run sysbench by specifying a test name, a command such as prepare, run, or cleanup, and any options for thread count, duration, or test-specific settings.

The output from a run includes rate statistics showing events per second alongside latency numbers, with percentile breakdowns and histograms. This makes it practical for capacity planning, for checking whether a configuration change improved throughput, or for stress-testing a database server before putting it into production.

Where it fits