stress-ng vs sysbench
A practical guide to two common Linux load-generation tools: what each one does, how they differ, and when to use them.
1. Overview
| stress-ng | sysbench | |
|---|---|---|
| Primary goal | Stress testing and fault finding | Benchmarking and performance measurement |
| One-line summary | Designed to break things | Designed to measure things |
2. stress-ng
stress-ng loads a system's hardware and kernel interfaces in many different ways. It is a much larger successor to the original stress tool.
Core features
- Large set of stressors: 300+ built-in tests, each exercising a specific part of the system.
-
CPU stress: Many compute methods (integer, floating point, matrix, FFT, bit operations, hashing) via
--cpuand--cpu-method. -
Memory stress: Virtual memory, cache, memory copy,
mmap, page faults, NUMA, via--vm,--cache,--memcpy,--mmap. -
I/O and filesystem stress: Disk reads/writes,
fsync, file locking, directory operations, via--hdd,--io,--dir. - Kernel interface stress: Syscalls, signals, pipes, sockets, semaphores, message queues, futexes, threads, context switches, scheduler.
- Network stress: Socket and protocol-level tests.
-
Device and driver stress:
ioctl,/dev,/procand/sysinterfaces.
Control and configuration
| Option | Purpose |
|---|---|
--cpu 4 / --cpu 0
|
Number of workers (0 = all online CPUs) |
--timeout 60s |
Stop after a set time |
--cpu-ops N |
Stop after N operations |
--cpu-load 50 |
Target a CPU utilization percentage |
--class cpu |
Run a group of stressors (cpu, memory, io, scheduler, ...) |
--all, --random, --sequential
|
Permutation modes |
-x |
Exclude specific stressors |
Measurement and reporting
- Bogo ops: A rough throughput measure, useful for same-machine comparison but not a formal benchmark.
-
Metrics:
--metrics/--metrics-brieffor summaries;--yamlor--log-fileto save results. -
Thermal and perf data:
--thermalstat,--vmstat,--perf. -
Verification:
--verifychecks that results are correct, helping catch hardware faults or memory errors.
Common uses
- Burn-in and stability testing of new hardware
- Checking cooling and thermal throttling
- Finding kernel bugs or race conditions
- Testing behavior under resource pressure (CPU, RAM, I/O)
Example commands
# Stress all CPUs for 60 seconds with a summary
stress-ng --cpu 0 --timeout 60s --metrics-brief
# 4 CPU workers, 2 VM workers using 1GB each, 1 disk worker
stress-ng --cpu 4 --vm 2 --vm-bytes 1G --hdd 1 --timeout 120s --metrics-brief
# Run every CPU-class stressor in turn
stress-ng --class cpu --sequential 0 --timeout 30s
Caution: stress-ng can make a system unresponsive, overheat, or crash, and some stressors can fill disks or trigger the OOM killer. Use it on test machines or with sensible limits, not carelessly on production.
3. sysbench
sysbench is a scriptable benchmark tool that produces repeatable performance numbers for CPU, memory, disk, threads, and databases.
Core features
- CPU: Prime number computation benchmark.
- Memory: Read/write throughput tests.
- File I/O: Sequential and random read/write tests.
- Threads and mutex: Scheduler and locking performance.
- Database (OLTP): Workloads for MySQL and PostgreSQL.
- Lua scripting: Write custom workloads.
Example commands
# CPU benchmark
sysbench cpu --threads=4 --time=30 run
# Memory throughput
sysbench memory --threads=4 run
# File I/O
sysbench fileio --file-total-size=2G prepare
sysbench fileio --file-total-size=2G --file-test-mode=rndrw run
sysbench fileio --file-total-size=2G cleanup
4. Key Differences
| Aspect | stress-ng | sysbench |
|---|---|---|
| Purpose | Stress testing, fault finding | Benchmarking, performance comparison |
| Scope | Very broad (300+ stressors) | Narrow: CPU, memory, file I/O, threads, database |
| Output | Bogo ops (rough, same-machine only) | Events/sec, latency percentiles, MiB/sec |
| Database testing | None | Strong (OLTP for MySQL/PostgreSQL) |
| Correctness checking | Yes (--verify) |
No, measures speed only |
| Extensibility | Modify the C source | Lua scripts |
5. Which One Should You Use?
| Goal | Recommended tool |
|---|---|
| Burn-in, thermal, or stability testing | stress-ng |
| Kernel bug hunting | stress-ng |
| Comparing two servers or VM sizes | sysbench |
| Measuring the effect of tuning changes | sysbench |
| Database server performance | sysbench |
Using them together
The two tools complement each other:
- Run stress-ng to confirm the system stays stable under heavy load.
- Run sysbench to record how fast the system actually is.
6. Summary
- stress-ng answers: "Does this system survive heavy load?"
- sysbench answers: "How fast is this system?"
References:
Top comments (0)