Server Performance Benchmarking Tools

From Server rental store
Jump to navigation Jump to search

Server Performance Benchmarking Tools

This guide provides a practical, hands-on approach to benchmarking your server's performance using common Linux tools. Understanding your server's capabilities is crucial for troubleshooting, capacity planning, and ensuring optimal performance, especially when hosting demanding applications or services. For dedicated server solutions offering full root access and excellent performance, consider exploring options at PowerVPS.

Introduction

Benchmarking is the process of running standardized tests to evaluate the performance of a system. This article covers four essential tools:

  • sysbench: A flexible scriptable system performance benchmarking tool. It can test CPU, memory, I/O, and database performance.
  • fio (Flexible I/O Tester): A powerful tool for I/O performance benchmarking. It can simulate various I/O workloads.
  • iperf3: A tool for active network bandwidth measurement. It measures the maximum achievable bandwidth on IP networks.
  • stress-ng: A tool to stress test a computer system by performing a variety of stressful operations.

Prerequisites

Before you begin, ensure you have the following:

  1. A Linux server with root or sudo privileges.
  2. SSH access to your server.
  3. Basic understanding of the Linux command line.
  4. Internet connectivity to download and install tools.
  5. For network tests (iperf3), you will need at least two machines: a client and a server.

Installation

The installation process varies slightly depending on your Linux distribution.

Debian/Ubuntu

sudo apt update
sudo apt install sysbench fio iperf3 stress-ng -y

CentOS/RHEL/Fedora

sudo yum update # or sudo dnf update for Fedora
sudo yum install sysbench fio iperf3 stress-ng -y # or sudo dnf install ...

Benchmarking with sysbench

sysbench is excellent for testing CPU, memory, and disk I/O.

CPU Performance Test

This test measures how quickly the CPU can perform complex calculations.

  1. Generate a test file:
sysbench cpu --threads=4 run
  • Replace `4` with the number of CPU cores you want to test.

Memory Performance Test

This test measures memory read/write speeds.

  1. Run the memory test:
sysbench memory run
  • This will use all available memory. For specific memory sizes, you can use options like `--memory-block-size=1K --memory-total-size=128M`.

Disk I/O Performance Test

This test measures sequential and random read/write speeds.

  1. Prepare the test directory (e.g., `/mnt/test_disk`):
sudo mkdir -p /mnt/test_disk
sudo chown $(whoami):$(whoami) /mnt/test_disk # Or appropriate user
  1. Run a sequential read/write test:
sysbench fileio --threads=4 --file-total-size=10G --file-test-mode=seqwr run
sysbench fileio --threads=4 --file-total-size=10G --file-test-mode=seqrd run
  • `--file-total-size`: The total size of files to be used for testing.
  • `--file-test-mode`: `seqwr` for sequential write, `seqrd` for sequential read.
  1. Run a random read/write test:
sysbench fileio --threads=4 --file-total-size=10G --file-test-mode=rndwr run
sysbench fileio --threads=4 --file-total-size=10G --file-test-mode=rndrd run
  • `--file-test-mode`: `rndwr` for random write, `rndrd` for random read.

Benchmarking with fio

fio is highly configurable and can simulate complex I/O patterns.

Basic Sequential Read/Write Test

  1. Create a test file and perform sequential writes:
fio --name=seqwrite --ioengine=libaio --iodepth=64 --rw=write --bs=1M --size=10G --directory=/mnt/test_disk --filename=testfile.dat --direct=1 --numjobs=4
  1. Perform sequential reads on the created file:
fio --name=seqread --ioengine=libaio --iodepth=64 --rw=read --bs=1M --size=10G --directory=/mnt/test_disk --filename=testfile.dat --direct=1 --numjobs=4
  • `--ioengine`: The I/O engine to use (e.g., `libaio` for asynchronous I/O).
  • `--iodepth`: The number of I/O operations to keep outstanding.
  • `--rw`: The I/O pattern (`read`, `write`, `randread`, `randwrite`, `rw`).
  • `--bs`: Block size.
  • `--size`: Total size of the I/O.
  • `--numjobs`: Number of parallel jobs.
  • `--direct=1`: Bypass the operating system's page cache.

Basic Random Read/Write Test

  1. Perform random writes:
fio --name=randwrite --ioengine=libaio --iodepth=64 --rw=randwrite --bs=4K --size=10G --directory=/mnt/test_disk --filename=testfile.dat --direct=1 --numjobs=4
  1. Perform random reads:
fio --name=randread --ioengine=libaio --iodepth=64 --rw=randread --bs=4K --size=10G --directory=/mnt/test_disk --filename=testfile.dat --direct=1 --numjobs=4
  • Note the smaller block size (`4K`) commonly used for random I/O.

Benchmarking Network with iperf3

iperf3 measures network throughput between two hosts. You'll need one machine as the server and another as the client.

Server Setup

  1. On the machine that will act as the iperf3 server:
iperf3 -s
  • This will start iperf3 in server mode, listening on the default port 5201.

Client Setup

  1. On the machine that will act as the iperf3 client:
iperf3 -c <server_ip_address>
  • Replace `<server_ip_address>` with the IP address of the iperf3 server.
  1. To test in reverse (client sending to server):
iperf3 -c <server_ip_address> -R
  1. To test for a longer duration (e.g., 30 seconds):
iperf3 -c <server_ip_address> -t 30

Stress Testing with stress-ng

stress-ng can be used to apply load to CPU, memory, and other system components. This is useful for stability testing.

CPU and Memory Stress Test

  1. Stress all available CPU cores and memory:
sudo stress-ng --cpu 0 --vm 2 --vm-bytes 1G --timeout 60s
  • `--cpu 0`: Stress all available CPU cores.
  • `--vm 2`: Start 2 virtual memory workers.
  • `--vm-bytes 1G`: Allocate 1GB of memory per worker.
  • `--timeout 60s`: Run the test for 60 seconds.

Disk I/O Stress Test

  1. Stress disk I/O (requires root privileges):
sudo stress-ng --hdd 2 --timeout 60s
  • `--hdd 2`: Start 2 hard drive stress workers.

Troubleshooting

  • Permission Denied: Ensure you are running commands with `sudo` when necessary, especially for disk I/O tests that write to system directories or require raw device access. For disk tests, consider using a dedicated partition or directory owned by your user.
  • Network Issues: Firewalls can block iperf3 traffic. Ensure port 5201 (or the port you specify with `-p`) is open on the server's firewall.
  • Inaccurate Results: Ensure you are not running other heavy processes on the server during the benchmark. For disk tests, make sure to test on the actual storage you intend to use. For network tests, ensure the network path between client and server is not saturated by other traffic.
  • `fio` or `sysbench` not found: Double-check your installation steps.

Related Articles