Skip to content

Automated Performance Benchmarking Suite for Infrastructure Migration Assessment

Notifications You must be signed in to change notification settings

dimas-sh/p2v_benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Server Performance Benchmarking Suite

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Shell Script](https://img.shields.io/badge/Shell-Bash-green.svg)](https://www.gnu.org/software/bash/)
[![Platform](https://img.shields.io/badge/Platform-Ubuntu%2024.04-orange.svg)](https://ubuntu.com/)

**Production-ready automated benchmarking toolkit for infrastructure migration decisions.**

Make data-driven migration decisions between bare-metal and VPS infrastructure with comprehensive performance analysis, automated reporting, and executive summaries.

---

## 📋 Table of Contents

- [Overview](#overview)
- [Features](#features)
- [Quick Start](#quick-start)
- [What Gets Tested](#what-gets-tested)
- [Installation](#installation)
- [Usage](#usage)
- [Output Examples](#output-examples)
- [Interpreting Results](#interpreting-results)
- [Methodology](#methodology)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)

---

## 🎯 Overview

This toolkit automates performance benchmarking across multiple dimensions (CPU, RAM, Disk I/O, Network) to provide objective, reproducible metrics for comparing servers. Perfect for:

- **Infrastructure migration planning** (bare-metal → VPS)
- **Provider comparison** (AWS vs Azure vs GCP vs Hetzner)
- **Performance regression testing**
- **Capacity planning validation**
- **SLA verification**

### Why This Tool?**Automated & Reproducible** - One command, consistent results  
✅ **Production-Tested** - Battle-hardened parameters based on real workloads  
✅ **Executive-Friendly** - Generates non-technical summaries with risk assessment  
✅ **Comprehensive** - Tests all critical performance dimensions  
✅ **Zero-Config** - Auto-installs dependencies, handles errors gracefully  

---

## ✨ Features

### Benchmarking Capabilities

| Component | Tests | Metrics |
|-----------|-------|---------|
| **CPU** | Multi-core stress, single-thread performance | Bogo ops/s, events/s, load average |
| **RAM** | Memory allocation, bandwidth throughput | MiB/s, usage, swap |
| **Disk I/O** | Sequential R/W (1MB), Random R/W (4K) | IOPS, MB/s, latency (µs) |
| **Network** | Bandwidth, latency (manual) | Gbps, jitter, packet loss |

### Reporting Features

- 📊 **Colored CLI output** with progress indicators
- 📄 **Technical report** (benchmark_report_*.txt) - Detailed metrics tables
- 📋 **Executive summary** (executive_summary_*.txt) - Risk assessment, recommendations, Q&A
- 🎨 **Side-by-side comparison** with percentage differences
- 📈 **Migration decision matrix** (GO/NO-GO/CONDITIONAL)

### Advanced Features

- ✅ Automatic dependency installation (stress-ng, fio, sysbench, iperf3)
- ✅ Error handling - continues on failure, collects partial results
- ✅ Configurable test parameters (duration, file size, workers)
- ✅ Machine-readable CSV logs for custom analysis
- ✅ Diagnostic tools for troubleshooting failed tests

---

## 🚀 Quick Start

### 30-Second Demo

```bash
# On Server 1 (bare-metal)
wget https://raw.githubusercontent.com/yourusername/repo/main/run.sh
chmod +x run.sh
sudo ./run.sh

# On Server 2 (VPS)
wget https://raw.githubusercontent.com/yourusername/repo/main/run.sh
chmod +x run.sh
sudo ./run.sh

# On your analysis machine
wget https://raw.githubusercontent.com/yourusername/repo/main/parse_results.sh
chmod +x parse_results.sh

# Copy logs from both servers
scp user@server1:/path/benchmark_logs_* ./
scp user@server2:/path/benchmark_logs_* ./

# Generate comparison report
./parse_results.sh benchmark_logs_server1_* benchmark_logs_server2_*

# View reports
cat benchmark_report_*.txt           # Technical details
cat executive_summary_*.txt          # For management

Total time: ~15 minutes per server


🧪 What Gets Tested

CPU Performance

  • Multi-core stress: All CPU cores under sustained load (60s)
  • Single-thread: Prime number calculation (sysbench)
  • Metrics: Computational throughput, load average

Why it matters: Application responsiveness, request processing speed

RAM Performance

  • Stress test: Memory allocation/deallocation patterns (30s)
  • Bandwidth test: Memory bus throughput (10GB transfer)
  • Metrics: MiB/s, peak usage, swap utilization

Why it matters: In-memory caching (Redis), data processing, analytics

Disk I/O Performance

  • Sequential Read: Large block reads (1MB blocks, 60s)
  • Sequential Write: Large block writes (1MB blocks, 60s)
  • Random Read: Database-style access (4K blocks, 32 I/O depth, 60s)
  • Random Write: Database writes (4K blocks, 32 I/O depth, 60s)
  • Metrics: IOPS, MB/s, latency

Why it matters: Database performance, file operations, VM disk I/O

Network Performance (Manual)

  • Bandwidth: TCP throughput test (iperf3)
  • Latency: RTT and jitter measurement
  • Metrics: Mbps/Gbps, packet loss, retransmits

Why it matters: API response times, data transfer speeds


📦 Installation

Prerequisites

  • Ubuntu 24.04 LTS (or compatible)
  • Root/sudo access
  • 10GB free disk space (for test files)
  • Internet connection (for dependency installation)

Git Clone

git clone https://github.com/dimas-sh/p2v_benchmark.git
cd repo
chmod +x *.sh

Verify Installation

bash -n run.sh              # Check syntax
./run.sh --help             # Should show usage

📖 Usage

Basic Workflow

Step 1: Run Benchmarks on Each Server

# Execute on BOTH servers you want to compare
sudo ./run.sh

# Output: benchmark_logs_<hostname>_<timestamp>/

Duration: 10-15 minutes per server
Requirements: Root access, ~10GB temp space

Step 2: Collect Logs

# On each server
tar czf logs.tar.gz benchmark_logs_*

# Copy to analysis machine
scp user@server1:/path/logs.tar.gz ./server1_logs.tar.gz
scp user@server2:/path/logs.tar.gz ./server2_logs.tar.gz

# Extract
tar xzf server1_logs.tar.gz
tar xzf server2_logs.tar.gz

Step 3: Generate Reports

./parse_results.sh benchmark_logs_server1_* benchmark_logs_server2_*

Outputs:

  • benchmark_report_<timestamp>.txt - Technical report
  • executive_summary_<timestamp>.txt - Management summary

Advanced Usage

Customize Test Parameters

Edit run.sh before running:

# Test duration (seconds)
readonly CPU_TEST_DURATION=60
readonly DISK_TEST_DURATION=60
readonly RAM_TEST_DURATION=30

# Test sizes
readonly RAM_TEST_SIZE="4G"        # 50% of total RAM recommended
readonly DISK_TEST_SIZE="4G"       # >= 2x RAM for accuracy

# I/O depth (concurrent operations)
readonly FIO_IODEPTH=32            # Higher = more parallelism

Diagnostic Mode

If tests fail or produce unexpected results:

./diagnose_logs.sh benchmark_logs_server_*/

# Shows:
# - Which tests completed
# - Raw values extracted
# - File structure
# - Parsing issues

Re-run Specific Tests

# Only CPU tests
sudo stress-ng --cpu 8 --timeout 60s --metrics-brief
sudo sysbench cpu --threads=1 --cpu-max-prime=20000 run

# Only disk tests
sudo fio --name=test --filename=/tmp/test --rw=randread --bs=4k --direct=1 --runtime=60

📊 Output Examples

Console Output

[INFO] Starting benchmark suite v1.0.0
[INFO] Hostname: production-server-01
[INFO] Timestamp: 20241222_153045

=== Phase 1: System Info ===
[INFO] System info saved to benchmark_logs_*/00_system_info.txt

=== Phase 2: CPU Tests ===
[INFO] Running CPU multi-core stress test (60s)...
[INFO] CPU multi-core test completed
[INFO] Cooldown for 15s...
[INFO] Running CPU single-core test with sysbench...
[INFO] CPU single-core test completed

=== Phase 3: RAM Tests ===
...

========================================
Benchmark completed successfully!
Results saved to: benchmark_logs_production-server-01_20241222_153045
========================================

Technical Report Sample

═══════════════════════════════════════════════════════════════════════
            PERFORMANCE BENCHMARK COMPARISON REPORT
═══════════════════════════════════════════════════════════════════════

SERVERS COMPARED:

  ▪ bare-metal-prod
    CPU: Intel Xeon E5-2680 v4 @ 2.40GHz
    RAM: 65536 MB
    Logs: benchmark_logs_bare-metal_20241222_120000

  ▪ vps-candidate
    CPU: AMD EPYC 7763 @ 2.45GHz
    RAM: 32768 MB
    Logs: benchmark_logs_vps_20241222_130000

┌─ CPU PERFORMANCE ──────────────────────────────────────────────────────┐
Server               Workers  Bogo ops/s      Load Avg    Single ops/s
────────────────────────────────────────────────────────────────────────────
bare-metal-prod           28   52340.12         27.80        9876.54
vps-candidate             16   41230.88         15.90        9102.33
────────────────────────────────────────────────────────────────────────────
Difference                 -     -21.23%            -          -7.84%
└────────────────────────────────────────────────────────────────────────┘

┌─ DISK I/O PERFORMANCE ─────────────────────────────────────────────────┐
Random Operations (4K):
Server               Read IOPS      Write IOPS  R Latency(µs)
────────────────────────────────────────────────────────────────────────────
bare-metal-prod      15234.00        10456.00       234.56
vps-candidate         5678.00         3234.00       567.89
────────────────────────────────────────────────────────────────────────────
Difference            -62.73%         -69.07%            -
└────────────────────────────────────────────────────────────────────────┘

Executive Summary Sample

================================================================================
                    EXECUTIVE SUMMARY
              Infrastructure Migration Assessment
================================================================================

Date: December 22, 2024
Assessment Type: Performance Benchmark Comparison
Source Server: bare-metal-prod (Current Infrastructure)
Target Server: vps-candidate (Proposed Migration)

================================================================================
PERFORMANCE COMPARISON SUMMARY
================================================================================

┌──────────────────────────────────────────────────────────────────────────┐
│ METRIC                  │ STATUS              │ PERFORMANCE DELTA        │
├──────────────────────────────────────────────────────────────────────────┤
│ CPU Performance         │ ACCEPTABLE: -7.8%   │                   -7.8%  │
│ Disk Read IOPS          │ CRITICAL: -62.7%    │                  -62.7%  │
│ Disk Write IOPS         │ CRITICAL: -69.1%    │                  -69.1%  │
│ RAM Bandwidth           │ ACCEPTABLE: -16.3%  │                  -16.3%  │
└──────────────────────────────────────────────────────────────────────────┘

================================================================================
OVERALL ASSESSMENT
================================================================================

Status: HIGH RISK - NOT RECOMMENDED
Risk Level: HIGH

RECOMMENDATION: Do NOT proceed with migration

RATIONALE:
  • Multiple critical performance degradations detected (2 metrics)
  • Significant impact expected on application performance
  • VPS infrastructure shows substantial limitations for current workload

SUGGESTED ACTIONS:
  1. Re-evaluate VPS provider and tier selection
  2. Consider dedicated CPU/storage VPS options
  3. Perform application-specific load testing
  4. Assess if workload can be optimized for lower IOPS requirements

📈 Interpreting Results

Risk Level Classification

Risk Criteria Action
LOW No critical degradations PROCEED with migration
MEDIUM 1 critical degradation ⚠️ CONDITIONAL - Validate impact
HIGH 2+ critical degradations DO NOT PROCEED - Re-evaluate

Degradation Thresholds

Metric Acceptable Moderate Critical
CPU Performance < 10% loss 10-15% loss > 15% loss
Disk IOPS < 20% loss 20-30% loss > 30% loss
RAM Bandwidth < 15% loss 15-25% loss > 25% loss

Common Patterns

✅ Good Migration Candidate

CPU: +10% (newer processor)
RAM: -15% (acceptable for web apps)
Disk: +200% (SSD upgrade)

Verdict: Proceed - Better overall performance

⚠️ Conditional Migration

CPU: -5% (minor loss)
RAM: -70% (severe, but not critical for your workload)
Disk: +100% (major improvement)

Verdict: Conditional - Validate RAM impact on your specific applications

❌ Poor Migration Candidate

CPU: -20% (significant loss)
RAM: -50% (severe)
Disk: -65% (IOPS degradation)

Verdict: Do not proceed - Investigate alternative providers


🔬 Methodology

Test Parameters Rationale

Why 60-second duration?

  • < 30s: Results unstable (cache warming, thermal effects)
  • 30-60s: Optimal balance (stable results, minimal throttling)
  • 120s: Diminishing returns, thermal throttling begins

Why 4K random I/O?

  • Standard database page size (MySQL, PostgreSQL)
  • Represents 90% of real-world database operations
  • Industry-standard benchmark parameter

Why Direct I/O?

  • Bypasses filesystem cache
  • Tests actual disk performance, not RAM
  • Matches database behavior (O_DIRECT flag)

Why multiple workers/jobs?

  • Modern applications are concurrent (100+ connections)
  • Single-threaded tests don't reflect production reality
  • Tests system under realistic load

Tools Selection

Tool Why Chosen
stress-ng Industry standard, comprehensive stress methods
sysbench De facto standard for database benchmarking
fio Gold standard for storage testing (used by Intel, Samsung)
iperf3 Network performance standard, widely validated

Industry Standards Compliance

  • ✅ Follows TPC (Transaction Processing Performance Council) guidelines
  • ✅ Aligned with SPEC (Standard Performance Evaluation Corporation) methodologies
  • ✅ Compatible with cloud provider benchmarking practices (AWS, Azure, GCP)

🛠️ Troubleshooting

Common Issues

Problem: "Permission denied"

# Solution: Run with sudo
sudo ./run.sh

Problem: "Package not found"

# Solution: Update package cache
sudo apt-get update
sudo apt-get install stress-ng fio sysbench iperf3 sysstat bc

Problem: Tests show "0" or "N/A" values

# Diagnosis
./diagnose_logs.sh benchmark_logs_*/

# Common causes:
# 1. Insufficient disk space
df -h

# 2. CPU throttling
cat /proc/cpuinfo | grep MHz

# 3. Storage mounted as noexec
mount | grep noexec

Problem: Disk tests extremely slow

# Check if testing on network mount
mount | grep nfs
mount | grep cifs

# Solution: Specify local disk path
# Edit run.sh: --filename=/dev/sda1 (local disk)

Problem: RAM test uses swap

# Check available RAM
free -h

# Solution: Reduce RAM_TEST_SIZE in run.sh
readonly RAM_TEST_SIZE="2G"  # Use less than available

Debug Mode

# Enable verbose output
bash -x ./run.sh 2>&1 | tee debug.log

# Check specific test
grep "ERROR\|WARN" benchmark_logs_*/

Getting Help

  1. Check Issues
  2. Run diagnostic: ./diagnose_logs.sh benchmark_logs_*/
  3. Share diagnostic output when reporting issues

🤝 Contributing

Contributions welcome! Please follow these guidelines:

Areas for Contribution

  • 🆕 Additional benchmark tests (GPU, network latency)
  • 🐛 Bug fixes and error handling improvements
  • 📚 Documentation improvements
  • 🌍 Multi-distribution support (CentOS, Debian, Arch)
  • 🎨 Output formatting enhancements
  • 📊 Additional export formats (JSON, HTML)

Development Setup

git clone https://github.com/dimas-sh/p2v_benchmark.git
cd repo

# Create feature branch
git checkout -b feature/your-feature-name

# Make changes, test thoroughly
sudo ./run.sh  # Test on multiple systems

# Submit PR with:
# - Description of changes
# - Test results on Ubuntu 24.04
# - Updated documentation (if applicable)

Code Style

  • Use shellcheck for linting: shellcheck *.sh
  • Follow Google Shell Style Guide
  • Add comments for complex logic
  • Test on clean Ubuntu 24.04 VM

📄 License

MIT License - see LICENSE file for details


🙏 Acknowledgments

Built with industry-standard tools:

Inspired by real-world infrastructure migration challenges.


📞 Support


⭐ Star History

If this project helped you make better infrastructure decisions, please consider giving it a star!

Star History Chart


Made with ❤️ for DevOps engineers making data-driven decisions


---

## 3. Additional Files to Include

### LICENSE (MIT)

MIT License

Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


### .gitignore

```gitignore
# Benchmark logs
benchmark_logs_*/
*.tar.gz
*.zip

# Generated reports
benchmark_report_*.txt
executive_summary_*.txt

# Temporary files
*.log
*.tmp
fio_test_file
*.yaml

# Editor files
*.swp
*.swo
*~
.vscode/
.idea/

# OS files
.DS_Store
Thumbs.db

CHANGELOG.md

# Changelog

All notable changes to this project will be documented in this file.

## [1.0.0] - 2024-12-22

### Added
- Initial release
- Automated CPU benchmarking (multi-core and single-thread)
- RAM performance testing (stress and bandwidth)
- Disk I/O testing (sequential and random)
- Network testing framework (manual iperf3)
- Automated report generation
- Executive summary with risk assessment
- Diagnostic tools for troubleshooting
- Error handling and graceful degradation
- CSV log format for custom analysis

### Features
- Auto-dependency installation
- Colored CLI output with progress indicators
- Side-by-side server comparison
- Migration decision recommendations
- Comprehensive documentation

4. Repository Structure

server-benchmark-suite/
├── README.md                    # Main documentation
├── LICENSE                      # MIT License
├── CHANGELOG.md                 # Version history
├── .gitignore                   # Git ignore rules
├── run.sh                       # Main benchmark script
├── parse_results.sh             # Report generator
├── diagnose_logs.sh             # Diagnostic tool
├── docs/
│   ├── METHODOLOGY.md          # Detailed testing methodology
│   ├── TROUBLESHOOTING.md      # Extended troubleshooting guide
│   └── EXAMPLES.md             # Real-world usage examples
└── examples/
    ├── sample_report.txt       # Example technical report
    └── sample_executive.txt    # Example executive summary

Releases

No releases published

Packages

No packages published

Languages