🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux Disk I/O Benchmarking with Python: Measure Read/Write Speed, IOPS, and Latency (Free CLI Tool)

Linux Disk I/O Benchmarking with Python: Measure Read/Write Speed, IOPS, and Latency (Free CLI Tool)

Disk I/O performance is one of the most critical factors in server and application performance. Slow storage causes everything from high database query latency to slow deployments. But measuring disk performance properly requires more than just running dd — you need sequential throughput, random IOPS, and latency measurements to get the full picture.

dargslan-disk-benchmark is a free Python CLI tool that runs a comprehensive disk I/O benchmark on any filesystem path. It measures sequential read/write speed, random read/write IOPS, and write latency with percentile breakdowns — all with zero dependencies.

Quick Start

pip install dargslan-disk-benchmark

dargslan-diskbench report              # Full benchmark
dargslan-diskbench write -s 100        # Sequential write (100 MB)
dargslan-diskbench read -s 100         # Sequential read (100 MB)
dargslan-diskbench iops                # Random IOPS test
dargslan-diskbench latency             # Write latency (P50/P95/P99)
dargslan-diskbench report -p /mnt/ssd  # Benchmark specific path

Understanding Disk Performance Metrics

Three key metrics define disk performance:

  • Sequential throughput (MB/s): How fast the disk reads or writes large contiguous blocks. This matters for backups, log writes, and file transfers. Modern NVMe SSDs can exceed 3000 MB/s.
  • Random IOPS: How many small random read/write operations per second the disk can handle. This is critical for databases, virtual machines, and web applications. Enterprise NVMe drives deliver 500K+ IOPS.
  • Write latency: How long each individual write operation takes. The P99 latency (99th percentile) shows worst-case behavior. For databases, sub-millisecond P99 latency is ideal.

How the Benchmark Works

The tool uses Python's standard library file operations with os.fsync() to ensure data actually hits the disk (not just the OS cache). For sequential tests, it writes/reads configurable block sizes. For IOPS tests, it performs random-position writes and reads. For latency, it measures individual 512-byte write + fsync operations and calculates percentile distributions.

Python API

from dargslan_disk_benchmark import DiskBenchmark

db = DiskBenchmark(path="/data")
results = db.full_benchmark(size_mb=100)

for test in results['tests']:
    if 'speed_human' in test:
        print(f"{test['test']}: {test['speed_human']}")
    elif 'iops' in test:
        print(f"{test['test']}: {test['iops']} IOPS")
    elif 'avg_ms' in test:
        print(f"{test['test']}: avg={test['avg_ms']}ms P99={test['p99_ms']}ms")

Comparing Storage Types

Use this tool to compare different storage backends: local SSD vs NFS, EBS gp3 vs io2, or before/after filesystem tuning. The JSON output mode makes it easy to store results for historical comparison.

Best Practices

  1. Run benchmarks on the actual filesystem where your application data lives
  2. Test with sizes larger than your RAM to avoid cache effects
  3. Run multiple rounds and average the results for consistency
  4. Compare P99 latency, not just averages — tail latency kills user experience
  5. Benchmark before and after any storage changes to quantify improvements

Conclusion

Understanding your disk I/O performance is essential for capacity planning and troubleshooting. dargslan-disk-benchmark gives you professional-grade benchmarking with zero setup. Install it and start measuring your storage performance today.

For more Linux performance tools, visit dargslan.com and explore our eBooks and cheat sheets.

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.