Created
February 5, 2023 14:41
-
-
Save azat/9f3fbf59c6f5ad42c5ae9a0d9a971e77 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
#!/usr/bin/env python3 | |
# Compare prices for cloud storage providers: | |
# - S3 - AWS S3 from Amazon | |
# https://aws.amazon.com/s3/pricing/ | |
# - GS/GCS - Google Cloud Storage | |
# https://cloud.google.com/storage/pricing#north-america | |
# - R2 - R2 from CloudFrame | |
# https://developers.cloudflare.com/r2/platform/pricing/ | |
import sys | |
def ranged_price(value, ranges): | |
cost = 0 | |
for limit, price in reversed(ranges.items()): | |
if value > limit: | |
cost += (value - limit) * price | |
value = limit | |
return cost | |
def r2(size_gb): | |
return size_gb*0.015 | |
def s3(size_gb): | |
price_ranges = { | |
0: 0.023, | |
50*1024: 0.022, | |
500*1024: 0.021, | |
} | |
return ranged_price(size_gb, price_ranges) | |
def gs(size_gb): | |
return size_gb * 0.020 | |
def gs_egress(size_gb): | |
price_ranges = { | |
0: 0.12, | |
1*1024: 0.11, | |
10*1024: 0.08, | |
} | |
return ranged_price(size_gb, price_ranges) | |
size_gb = int(sys.argv[1]) | |
print('### Cost') | |
print('- r2: {:,}$'.format(r2(size_gb))) | |
print('- s3: {:,}$'.format(s3(size_gb))) | |
print('- gs: {:,}$'.format(gs(size_gb) + gs_egress(size_gb))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment