Last active
February 5, 2024 03:24
-
-
Save thom-vend/c710e4fb173b4bea91bc12204c25ee86 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 | |
from icecream import ic | |
""" | |
Cost of burstable CPU credit above baseline: | |
- $0.09 per vCPU-Hour for Aurora Standard | |
- $0.12 per vCPU-Hour for Aurora I/O-Optimized clusters | |
Baseline cannot be foudn for aurora, but should be the same as ec2: | |
https://aws.amazon.com/ec2/instance-types/t4/ | |
t4g.large: 30% | |
t4g.medium: 20% | |
Standard aurora pricing not I/O optimized | |
db.r7g.large pricing: $0.276 per h | |
db.t4g.large pricing: $0.146 per h | |
db.t4g.medium pricing: $0.073 per h | |
""" | |
def compute_break_even( | |
r_price=0.276, # newer r7g price per hour | |
t_price=0.073, # t4g.medium price per hour | |
t_baseline=20, # % CPU included in the burstable | |
t_vCPU=2, # Number of vCPUs of the burstable instance | |
credit_price_per_h=0.09 # Price per vCPU hour | |
): | |
tr_price_diff = r_price - t_price | |
ic(tr_price_diff) | |
credit_price_per_min = credit_price_per_h / 60 | |
# from price diff: possible burst in min (without including the baseline) | |
burst_allowed_min = tr_price_diff / credit_price_per_min / t_vCPU | |
ic(burst_allowed_min) | |
burst_allowed_CPUusage = burst_allowed_min / 60 * 100 | |
ic(burst_allowed_CPUusage) | |
break_even = burst_allowed_CPUusage + t_baseline | |
return round(break_even, 2) | |
if __name__ == "__main__": | |
print(compute_break_even()) | |
print(compute_break_even(t_price=0.164, t_baseline=30)) # db.t3.large vs db.r7g.large | |
print(compute_break_even(r_price=0.260, t_price=0.164, t_baseline=30)) # db.t3.large vs db.r6g.large | |
print(compute_break_even(r_price=0.260, t_price=0.146, t_baseline=30)) # db.t4g.large vs db.r6g.large |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results: