Skip to content

Instantly share code, notes, and snippets.

@gubatron
Created February 23, 2012 02:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gubatron/1889173 to your computer and use it in GitHub Desktop.
Save gubatron/1889173 to your computer and use it in GitHub Desktop.
Testing disk I/O speed on a single EBS volume, vs a RAID0 volume made of 2 EBS volumes.
import os
import time
def writeBytes(size,fileName):
start = time.time()
cmd = "dd if=/dev/zero of=" + fileName + " bs=" + size + " count=1 status=noxfer > /dev/null"
print cmd
os.system(cmd)
return time.time() - start
SINGLE="/home/ubuntu/data/singleEBS"
RAID0="/home/ubuntu/data/raid0EBS"
#test with smaller sizes
FILE_SIZES=['4k','8k','16k','32k','64k','128k','256k','512k']
#test with bigger sizes
FILE_SIZES=['128M']
def writeNFiles(PATH,N):
total_time = 0
for size in FILE_SIZES:
for i in xrange(0,N):
total_time += writeBytes(size,PATH+"/"+size+"-"+str(i))
return total_time
total_time=0
REPETITIONS=1
N_FILES=9
for i in xrange(0,REPETITIONS):
total_time += writeNFiles(SINGLE,N_FILES)
outputA = "("+str(total_time)+") Total time for " + SINGLE
total_time=0
for i in xrange(0,REPETITIONS):
total_time += writeNFiles(RAID0,N_FILES)
outputB = "("+str(total_time)+") Total time for " + RAID0
print "\n\n"
print outputA
print outputB
print "\n"
#
# Results. Single EBS is faster when writing a lot of small files.
# RAID0 is faster when writing bigger files (from tens of MBs to over 128MB on this last test)
# AWS EBS EC2 tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment