Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 39598
1
# https://cloud.google.com/compute/pricing
2
3
# all storage prices are per GB per month.
4
PRICING = {
5
'gcs-standard' : 0.026,
6
'gcs-reduced' : 0.02,
7
'gcs-nearline' : 0.01,
8
'snapshot' : 0.026,
9
'local-ssd' : 0.218,
10
'pd-ssd' : 0.17,
11
'pd-standard' : 0.04,
12
13
'n1-standard-hour' : 0.0475, # for equivalent of -1, so multiply by number of cpu's (the suffix)
14
'n1-standard-hour-pre' : 0.01,
15
'n1-standard-month': 0.035*30.5*24, # price for sustained use for a month
16
'n1-standard-ram' : 3.75, # amount in GB of base machine
17
18
'n1-highmem-hour' : 0.1184/2,
19
'n1-highmem-hour-pre' : 0.025/2,
20
'n1-highmem-month' : 0.088*30.5*24/2,
21
'n1-highmem-ram' : 6.5,
22
23
'n1-highcpu-hour' : 0.0709/2,
24
'n1-highcpu-hour-pre' : 0.015/2,
25
'n1-highcpu-month' : 0.053*30.5*24/2,
26
'n1-highcpu-ram' : 0.9,
27
28
'g1-small-hour' : 0.0257,
29
'g1-small-hour-pre': 0.007,
30
'g1-small-month' : 0.019*30.5*24,
31
'g1-small-ram' : 1.7,
32
33
'f1-micro-hour' : 0.0076,
34
'f1-micro-hour-pre': 0.0035,
35
'f1-micro-month' : 0.0056*30.5*24,
36
'f1-micro-ram' : 0.60,
37
38
'europe' : 1.10105263157895,
39
'taiwan' : 1.15789473684211,
40
'japan' : 1.28421052631579,
41
'us' : 1,
42
43
'egress' : 0.12,
44
'egress-china' : 0.23,
45
'egress-australia' : 0.19,
46
}
47
48
def cpu_cost(size='n1-standard-1', preemptible=False, region='us'):
49
if size.count('-') == 2:
50
i = size.rfind('-')
51
m = int(size[i+1:])
52
else:
53
i = len(size)
54
m = 1
55
if preemptible:
56
x = PRICING[size[:i] + '-hour-pre']*24*30.5*m
57
return [x, x]
58
else:
59
return [m*PRICING[size[:i] + '-month'], m*PRICING[size[:i] + '-hour']*24*30.5]
60
61
def disk_cost(disk_size=10, disk_type='pd-standard'):
62
x = PRICING[disk_type] * disk_size
63
return [x, x]
64
65
import locale
66
locale.setlocale( locale.LC_ALL, '' )
67
def money(s):
68
return locale.currency(s)
69
70
71
72