Guide to Building an Automated VPS Performance Benchmark Suite for CPU, Disk I/O, Network, Database, and Weekly Reports
This guide details the construction of an automated VPS performance benchmark suite that regularly tests CPU, disk I/O, network, and database performance, then generates and sends...
Image credit: herbert2512 · Pixabay Content License
This guide details the construction of an automated VPS performance benchmark suite that regularly tests CPU, disk I/O, network, and database performance, then generates and sends weekly reports. The system uses CLI tools, shell scripts, and cron jobs to monitor and log metrics, enabling proactive detection of performance degradation and ensuring stable service delivery for applications sensitive to latency and throughput.
Key Features of the Benchmark Suite
The automated benchmark suite performs periodic tests and records results based on the following criteria:
- CPU Performance: Measures execution time, average load, and CPU utilization.
- Disk I/O Performance: Tests read/write speeds and drive access times.
- Network Performance: Measures data transfer rates, latency, and bandwidth.
- Database Performance: Executes basic queries and measures response times.
- Weekly Reporting: Sends email reports or stores results in files, summarizing trends over time.
Setup Environment and Required Tools
System requirements:
- Operating System: Linux (Ubuntu 22.04 or later)
- Required software:
sysbench: For CPU, Disk I/O, and Database benchmarkingiperf3: For Network benchmarkinghdparm: For Disk I/O benchmarkingmysql-clientorpostgresql-client: For Database benchmarkingcrontab: For scheduling script executionmailutils: For sending email reports (optional)
Install the required tools:
# Update package list and install tools
sudo apt update
sudo apt install -y sysbench iperf3 hdparm mailutils
# Install MySQL client (if testing MySQL)
sudo apt install -y mysql-client
Write the Performance Testing Script
Create the script at /usr/local/bin/vps-benchmark.sh with the following content:
#!/bin/bash
# Configuration variables
REPORT_DIR="/var/log/vps-benchmark"
DATE=$(date +%Y-%m-%d_%H-%M-%S)
LOG_FILE="$REPORT_DIR/report_$DATE.log"
# Create report directory
mkdir -p "$REPORT_DIR"
# 1. CPU Benchmark using sysbench
echo "=== CPU Benchmark ===" >> "$LOG_FILE"
sysbench cpu --cpu-max-prime=2000 run >> "$LOG_FILE" 2>&1
# 2. Disk I/O Benchmark using hdparm
echo -e "\n=== Disk I/O Benchmark ===" >> "$LOG_FILE"
hdparm -Tt /dev/vda >> "$LOG_FILE" 2>&1
# 3. Network Benchmark using iperf3 (requires iperf3 server on another machine)
echo -e "\n=== Network Benchmark ===" >> "$LOG_FILE"
# Run iperf3 client (replace 192.168.1.100 with the IP of the iperf3 server)
iperf3 -c 192.168.1.100 -t 10 >> "$LOG_FILE" 2>&1
# 4. Database Benchmark (MySQL)
echo -e "\n=== Database Benchmark ===" >> "$LOG_FILE"
# Run a simple query
mysql -h localhost -u root -p"your_password" -e "SELECT NOW();" >> "$LOG_FILE" 2>&1
# 5. Log completion time
echo -e "\n=== Completed at: $DATE ===" >> "$LOG_FILE"
# Send email report (if mailutils is available)
if command -v mail >/dev/null; then
mail -s "VPS Benchmark Report - $DATE" [email protected] < "$LOG_FILE"
fi
Make the script executable:
sudo chmod +x /usr/local/bin/vps-benchmark.sh
Schedule Automatic Execution with Cron
Open the crontab editor:
crontab -e
Add the following line to run the script every Sunday at 2:00 AM:
0 2 * * 0 /usr/local/bin/vps-benchmark.sh
Analyze and Report Results
Results are stored in /var/log/vps-benchmark/. Each run creates a separate log file. Trends can be analyzed by:
- Comparing database query times across weeks.
- Observing if disk I/O speeds are decreasing.
- Assessing network latency from different servers.
To automatically summarize weekly reports, additional analysis scripts can be written to parse logs and send aggregated emails.
Alternative Solutions and Notes
If cron is not preferred, consider using systemd timer or tools like Comparing VPS in Vietnam, Singapore, and Japan: Real Latency and Optimal Selection for Enterprises to choose the most suitable VPS.
Troubleshooting
- Script not running: Verify script permissions and correct path.
- Unable to send email: Check mailutils configuration and email server settings.
- No network results: Ensure the iperf3 server is running and accessible.
- Database connection failed: Verify password, access rights, and MySQL service status.
References
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
