Linux Server Benchmarking Tools and Techniques: Measure What Matters

Why Benchmark Your Servers?
Benchmarking establishes a performance baseline for your servers. Without benchmarks, you cannot know if a performance problem is real or perceived, whether a configuration change helped, or if your server is performing as expected for its hardware class.
When you deploy on ServerRaja cloud servers, benchmarking helps you choose the right plan, validate performance after migration, and detect degradation early.
CPU Benchmarking
Using sysbench
Sysbench is a versatile benchmarking tool that tests CPU, memory, and I/O:
# Install sysbench
sudo apt install sysbench# CPU benchmark: compute primes up to 20000 sysbench cpu --cpu-max-prime=20000 --threads=$(nproc) run
# Multi-threaded CPU test with increasing thread counts for threads in 1 2 4 8; do echo "=== $threads threads ===" sysbench cpu --cpu-max-prime=20000 --threads=$threads run done ```
Using stress-ng
stress-ng performs a wide range of CPU stress tests:
# Install stress-ng
sudo apt install stress-ng# CPU benchmark with various methods stress-ng --cpu 4 --cpu-method all --metrics-brief --timeout 60s
# Specific CPU methods stress-ng --cpu 4 --cpu-method matrixprod --timeout 30s stress-ng --cpu 4 --cpu-method fibonacci --timeout 30s ```
Using Geekbench (quick one-liner)
wget https://cdn.geekbench.com/Geekbench-6.2.2-Linux.tar.gz
tar xzf Geekbench-6.2.2-Linux.tar.gz
./geekbench6
Memory Benchmarking
Using sysbench
# Memory benchmark: sequential write
sysbench memory --memory-block-size=1M --memory-total-size=10G run# Memory benchmark: random access sysbench memory --memory-block-size=4K --memory-total-size=10G --memory-access-mode=rnd run
# Compare block sizes for block_size in 1K 4K 64K 1M 16M; do echo "=== Block size: $block_size ===" sysbench memory --memory-block-size=$block_size --memory-total-size=10G run done ```
Using stress-ng for memory
# Memory bandwidth test
stress-ng --vm 2 --vm-bytes 1G --vm-method all --metrics-brief --timeout 30s# Stream benchmark (measures real-world memory bandwidth) sudo apt install libomp-dev stress-ng --stream 4 --stream-index-size=0 --metrics-brief --timeout 30s ```
Using dd for simple memory throughput
# Write speed to /dev/null (tests memory copy speed)
dd if=/dev/zero bs=1M count=1024 | dd of=/dev/null bs=1M
Disk I/O Benchmarking
Using fio
fio is the gold standard for disk I/O benchmarking:
# Install fio
sudo apt install fio# Sequential read test fio --name=seq-read --ioengine=libaio --direct=1 --bs=1M \ --size=4G --numjobs=1 --rw=read --filename=/tmp/fio-test
# Sequential write test fio --name=seq-write --ioengine=libaio --direct=1 --bs=1M \ --size=4G --numjobs=1 --rw=write --filename=/tmp/fio-test
# Random read (4K) - simulates database workloads fio --name=rand-read-4k --ioengine=libaio --direct=1 --bs=4k \ --size=1G --numjobs=4 --iodepth=64 --rw=randread --filename=/tmp/fio-test
# Random write (4K) fio --name=rand-write-4k --ioengine=libaio --direct=1 --bs=4k \ --size=1G --numjobs=4 --iodepth=64 --rw=randwrite --filename=/tmp/fio-test
# Mixed random read/write (70/30 split, typical database workload) fio --name=rand-mixed --ioengine=libaio --direct=1 --bs=4k \ --size=1G --numjobs=4 --iodepth=64 --rw=randrw --rwmixread=70 \ --filename=/tmp/fio-test ```
Using ioping for latency
# Install ioping
sudo apt install ioping# Measure disk latency ioping -c 100 /tmp/
# Measure IOPS ioping -c 100 -i 1ms /tmp/
# Measure sequential throughput ioping -c 100 -S 1M /tmp/ ```
Interpreting Disk Results
For NVMe SSD drives on ServerRaja:
- Sequential read: expect 2000-7000 MB/s
- Sequential write: expect 1000-5000 MB/s
- Random 4K read IOPS: expect 100,000-500,000
- Random 4K write IOPS: expect 50,000-300,000
- Latency: expect 0.02-0.1ms for NVMe
Network Benchmarking
Using iperf3
# Install iperf3
sudo apt install iperf3# On the server (receiver) iperf3 -s
# On the client (sender) - TCP test iperf3 -c server-ip -t 30 -P 4
# UDP test iperf3 -c server-ip -u -b 10G -t 30
# Bidirectional test iperf3 -c server-ip --bidir -t 30 ```
Using netperf
# Install netperf
sudo apt install netperf# TCP request/response latency test netperf -H server-ip -t TCP_RR
# TCP stream throughput netperf -H server-ip -t TCP_STREAM
# UDP latency netperf -H server-ip -t UDP_RR ```
Ping latency baseline
# Extended ping test
ping -c 100 server-ip | tail -1# MTR for route analysis mtr -r -c 100 server-ip ```
Creating a Benchmark Script
Combine all tests into a reusable script:
#!/bin/bash
# benchmark.sh - Comprehensive server benchmarkecho "=========================================" echo "Server Benchmark - $(date)" echo "=========================================" echo ""
echo "--- System Info ---" uname -a cat /proc/cpuinfo | grep "model name" | head -1 free -h | head -2 df -h / echo ""
echo "--- CPU Benchmark ---" sysbench cpu --cpu-max-prime=20000 --threads=$(nproc) run 2>&1 | grep -E "events per second|total time" echo ""
echo "--- Memory Benchmark ---" sysbench memory --memory-block-size=1M --memory-total-size=10G run 2>&1 | grep -E "total time|transferred" echo ""
echo "--- Disk I/O Benchmark ---" fio --name=bench --ioengine=libaio --direct=1 --bs=4k --size=256M --numjobs=4 --iodepth=64 --rw=randrw --rwmixread=70 --filename=/tmp/fio-bench --minimal 2>&1 | awk -F';' '{print "Read IOPS:", $8, "Write IOPS:", $49, "Read Lat:", $40"us", "Write Lat:", $81"us"}' echo ""
echo "--- Network Latency ---" ping -c 20 8.8.8.8 | tail -1 echo ""
echo "=========================================" echo "Benchmark complete" ```
Conclusion
Regular benchmarking keeps you informed about your server performance. Run benchmarks when you first deploy, after configuration changes, and periodically to detect degradation. Use fio for disk testing, sysbench for CPU and memory, and iperf3 for network. Store results with timestamps to track performance trends over time on your ServerRaja cloud servers.