Created
May 19, 2010 19:19
-
-
Save wr0ngway/406721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TB usage at which pricing changes | |
s3_tiers = %w{50 100 500 1000 5000 1000000000}.collect {|x| x.to_f} | |
# Cost per GB/month for each of the above tiers | |
s3 = %w{0.15 0.14 0.13 0.105 0.08 0.055}.collect {|x| x.to_f} | |
s3_reduced = %w{0.1 0.093 0.087 0.07 0.053 0.037}.collect {|x| x.to_f} | |
# ebs is always 0.10/GB per month | |
ebs = %w{0.1 0.1 0.1 0.1 0.1 0.1}.collect {|x| x.to_f} | |
# google data is 0.17/GB/month | |
# rackspace files is 0.15/GB/month | |
# Using ec2 instances for storage | |
# large = 850GB at 0.34/hr = (0.34 * 24 * 31) / 850 = 0.2976 per GB/month | |
# reserved large 1 yr = 850GB at 0.12/hr with $910 fee = ((0.12 * 24 * 31) + (910 / 12)) / 850 = 0.1933 per GB/month | |
# reserved large 3 yr = 850GB at 0.12/hr with $1400 fee = ((0.12 * 24 * 31) + (1400 / 36)) / 850 = 0.1497 per GB/month | |
def calc_usage(usage, tiers, cost) | |
total = 0.0 | |
tiers.each_with_index do |t, i| | |
if usage <= t | |
total += cost[i] * usage * 1000 | |
break | |
else | |
total += cost[i] * t * 1000 | |
usage -= t | |
end | |
end | |
return total | |
end | |
tb_used = 1000 | |
puts "Monthly costs for #{tb_used}TB" | |
puts "S3: #{calc_usage(tb_used, s3_tiers, s3)}" | |
puts "S3 Reduced: #{calc_usage(tb_used, s3_tiers, s3_reduced)}" | |
puts "EBS: #{calc_usage(tb_used, s3_tiers, ebs)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment