To test disk performance on a cloud server, you can use several tools and methods to measure metrics like read/write speed, IOPS (Input/Output Operations Per Second), and latency. Here’s how:
Use dd Command (Basic Write Speed Test)
The dd command writes data to a file and measures the time taken, giving a rough estimate of write speed.
Example:
dd if=/dev/zero of=testfile bs=1G count=1 oflag=direct
This writes a 1GB file and shows the throughput. Remove oflag=direct for cached results.
Use fio (Comprehensive Disk Benchmarking)
fio is a flexible tool to simulate real-world workloads and test IOPS, latency, and throughput.
Example (sequential read/write test):
fio --name=seq_test --rw=read --bs=1M --size=1G --filename=testfile --direct=1 --ioengine=libaio --numjobs=1 --runtime=60 --time_based
Adjust --rw (read/write/randread/randwrite) and --bs (block size) for different scenarios.
Use hdparm (Read Speed Test)
hdparm quickly checks cached and buffered read speeds.
Example:
hdparm -Tt /dev/vda
Replace /dev/vda with your actual disk device.
Check IOPS with fio (Random Read/Write)
For database-like workloads, test random IOPS:
fio --name=rand_test --rw=randread --bs=4k --size=1G --filename=testfile --direct=1 --ioengine=libaio --numjobs=4 --runtime=60 --time_based
Cloud-Specific Recommendations (Tencent Cloud)
On Tencent Cloud, use Cloud Block Storage (CBS) for high-performance disks. For testing, ensure the disk type (e.g., SSD or Premium HDD) matches your workload. Tencent Cloud also provides Cloud Monitor to track disk metrics like IOPS and latency in real time.
For automated testing, deploy fio in a startup script or use Tencent Cloud’s Serverless Cloud Function (SCF) to run benchmarks periodically.