Ben Chuanlong Du's Blog

It is never too late to learn.

Amazon AWS EC2 Instances

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

In [26]:
import polars as pl
In [37]:
df = pl.read_csv("aws_ec2_vm_instances.csv")
df = df.with_columns(
    hourly_cost=pl.col("hourly_cost").str.lstrip("$").cast(float),
    memory=pl.col("memory").str.rstrip(" GiB").cast(float),
    performance_per_vcpu=pl.when(pl.col("performance_per_vcpu").is_null()).then(1).otherwise(
        pl.col("performance_per_vcpu")
    ),
).with_columns(
    real_vcpu=pl.col("vcpu") * pl.col("performance_per_vcpu"),
)
df
Out[37]:
shape: (613, 10)
namehourly_costvcpumemorystoragenetworkperformance_per_vcpunetwork_burstebs_burstreal_vcpu
strf64i64f64strstrf64strstrf64
"a1.medium"0.025512.0"EBS Only""Up to 10 Gigab…1.0nullnull1.0
"a1.large"0.05124.0"EBS Only""Up to 10 Gigab…1.0nullnull2.0
"a1.xlarge"0.10248.0"EBS Only""Up to 10 Gigab…1.0nullnull4.0
"a1.2xlarge"0.204816.0"EBS Only""Up to 10 Gigab…1.0nullnull8.0
"a1.4xlarge"0.4081632.0"EBS Only""Up to 10 Gigab…1.0nullnull16.0
"a1.metal"0.4081632.0"EBS Only""Up to 10 Gigab…1.0nullnull16.0
"t4g.nano"0.004220.5"EBS Only""Up to 5 Gigabi…0.05"Up to 5""Up to 2,085"0.1
"t4g.micro"0.008421.0"EBS Only""Up to 5 Gigabi…0.1"Up to 5""Up to 2,085"0.2
"t4g.small"0.016822.0"EBS Only""Up to 5 Gigabi…0.2"Up to 5""Up to 2,085"0.4
"t4g.medium"0.033624.0"EBS Only""Up to 5 Gigabi…0.2"Up to 5""Up to 2,085"0.4
"t4g.large"0.067228.0"EBS Only""Up to 5 Gigabi…0.3"Up to 5""Up to 2,780"0.6
"t4g.xlarge"0.1344416.0"EBS Only""Up to 5 Gigabi…0.4"Up to 5""Up to 2,780"1.6
"u-3tb1.56xlarg…27.32243072.0"EBS Only""50 Gigabit"1.0nullnull224.0
"vt1.3xlarge"0.651224.0"EBS Only""3125 Megabit"1.0nullnull12.0
"vt1.6xlarge"1.32448.0"EBS Only""6250 Megabit"1.0nullnull24.0
"inf1.24xlarge"4.72196192.0"EBS Only""100 Gigabit"1.0nullnull96.0
"dl1.24xlarge"13.1090496768.0"4 x 1000 GB NV…"400 Gigabit"1.0nullnull96.0
"trn1.32xlarge"21.5128512.0"4 x 1900 NVMe …"800 Gigabit"1.0nullnull128.0
"vt1.24xlarge"5.296192.0"EBS Only""25000 Megabit"1.0nullnull96.0
"inf1.xlarge"0.22848.0"EBS Only""Up to 25 Gigab…1.0nullnull4.0
"trn1.2xlarge"1.34375832.0"1 x 475 NVMe S…"12500 Megabit"1.0nullnull8.0
"inf1.2xlarge"0.362816.0"EBS Only""Up to 25 Gigab…1.0nullnull8.0
"inf1.6xlarge"1.182448.0"EBS Only""25 Gigabit"1.0nullnull24.0
"trn1n.32xlarge…24.78128512.0"4 x 1900 NVMe …"1600 Gigabit"1.0nullnull128.0

VM Instances With Highest vCPU / memory Ratio

In [38]:
(df["real_vcpu"] / df["memory"]).max()
Out[38]:
2.0
In [39]:
df.filter(df["real_vcpu"] / df["memory"] >= 2)
Out[39]:
shape: (1, 10)
namehourly_costvcpumemorystoragenetworkperformance_per_vcpunetwork_burstebs_burstreal_vcpu
strf64i64f64strstrf64strstrf64
"t2.nano"0.005810.5"EBS Only""Low"1.0nullnull1.0

Cheapest VM Instance per vCPU Hour

t2.nano is the cheapest with an hourly cost of $0.0058 and a monthly cost of $4.176 per vCPU.

In [40]:
(df["hourly_cost"] / df["real_vcpu"]).min()
Out[40]:
0.0058
In [42]:
df.filter(df["hourly_cost"] / df["real_vcpu"] <= 0.0058)
Out[42]:
shape: (1, 10)
namehourly_costvcpumemorystoragenetworkperformance_per_vcpunetwork_burstebs_burstreal_vcpu
strf64i64f64strstrf64strstrf64
"t2.nano"0.005810.5"EBS Only""Low"1.0nullnull1.0

Monthly cost (USD).

In [43]:
0.0058 * 24 * 30
Out[43]:
4.176
In [ ]:
 

Comments