forked from cooperative-computing-lab/makeflow-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamazon_price_calculator
67 lines (55 loc) · 2.57 KB
/
amazon_price_calculator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Amazon Web Services Price Calculator
#Caitlin Guccione
#07/28/2017
import math
#This data is from the general_purpose file which is the first item on the
#amazon EC3 website
#Assuming that you won't use: m4.large, m4.xlarge, m4.2xlarge since it's
#way cheaper to use t2.large, t2.xlarge and t2.2xlarge instead
def VM_price_calc(mem, cores, total_runtime):
'''Gives the price of the VM based on cores and memory requested '''
amz_memory= [0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 160.0, 256.0]
amz_price= [0.0059, 0.012, 0.023, 0.047, 0.094, 0.188, 0.376, 0.8, 2.0, 3.2]
amz_cores = [1, 1, 1, 2, 2, 4, 8, 16, 40, 64]
amz_machine= ['t2.nano', 't2.micro', 't2.small', 't2.medium', 't2.large', 't2.xlarge', 't2.2xlarge', 'm4.4xlarge', 'm4.10xlarge', 'm4.16xlarge']
count=0
final_num= 0
extra =0
extra_count =0
total_runtime = math.ceil(total_runtime)
while mem > 256 or cores > 64:
mem= mem - 256
cores = cores - 64
extra = extra + 3.2
print ("")
print ("You need a m4.16xlarge machine and ...")
for x in amz_memory:
if mem <= x:
if cores <= amz_cores[count]:
final_num=count
return (((amz_price[final_num] +extra)*total_runtime), (amz_machine[final_num]))
count+=1
#This assumes EBS General Purpose SSD (gp2) volume
def EBS_price_calc (input_f, input_h, output_f, output_h):
'''Gives the price of the EBS machine based on the size of the in/output files'''
input_total= (0.1 * input_f * input_h)/(24*30)
output_total=(0.1 * output_f * output_h)/(24*30)
total = input_total + output_total
return (total)
def main():
print ("This is all for a single machine")
mem=float(input("Enter the memory (GB) "))
cores=int(input("Enter the number of cores "))
total_runtime= float(input("Enter the number of hours running the program total "))
input_file_size=float(input("Enter the size of the input file (GB) "))
input_file_hours= float(input("Enter the hours of storage for the input file "))
output_file_size= float(input("Enter the size of the output file (GB) "))
output_file_hours= float(input("Enter the hours of storage for the output file "))
VM_total, machine=VM_price_calc(mem, cores, total_runtime)
EBS_total=EBS_price_calc(input_file_size, input_file_hours, output_file_size, output_file_hours)
total_price = VM_total + EBS_total
total_price= total_price
print ("You need a", machine, "machine")
print ("")
print ("Your total price is $", round(total_price, 2))
main()