CPU vs. memory cost calculation
Google Cloud Platform (GCP) is the only one of the three major cloud providers that divides compute pricing into CPU and memory costs. Amazon Web Services (AWS) and Microsoft Azure don’t provide this information at the moment.
CAST AI’s cost monitoring module uses a formula to calculate the separate CPU and memory costs for AWS and Azure. The implementation lets you:
- get more precise cost monitoring data,
- understand what you’re paying for better,
- see cost breakdown into workloads, namespaces, and allocation groups (the latter to be released).
This is especially important if you use a lot of memory optimized virtual machines.
The formula is based on the public data from GCP that was extrapolated to estimate the prices of memory and CPU for providers like AWS and Azure.
Some cloud instances have GPU and that resource pricing breakdown needs to be calculated including GPU ratio. We’re currently investigating this and will share the results soon!
Calculating CPU vs. memory pricing
AWS and GCP instances were mapped to calculate the CPU/memory costs based on the memory-to-CPU price ratio in GCP.
The following virtual machines across AWS and GCP were compared:
Resource family | GCP Compute Engine | AWS EC2 |
---|---|---|
General purpose | E2, N2, N2D, N1 | A1, M4, M5, M5a, M5n, M5zn, M6g, T2, T3, T3a, T4g, Mac |
Compute optimized | C2 | C4, C5, C5a, C5n, C6g, Cgn |
Memory optimized | M1, M2 | R4, R5, R5a, R5b, R5n, R6g, X1, X1e, High Memory, z1d |
CPU vs. memory in general purpose machines
The process started with a calculation of the memory-to-CPU ratio for general purpose machines that have predefined memory and vCPUs.
Machine type | Predefined | On-demand | Spot | ||
---|---|---|---|---|---|
E2 | In $ terms | Percentage | In $ terms | Percentage | |
Total price | $0.0247340 | $0.0074200 | |||
vCPU price | $0.0218110 | 88.18% | $0.0065430 | 88.18% | |
Memory price | $0.0029230 | 11.82% | $0.0008770 | 11.82 | |
N2 | In $ terms | Percentage | In $ terms | Percentage | |
Total price | $0.0358480 | $0.0086800 | |||
vCPU price | $0.0316110 | 88.18 | $0.0076500 | 88.13% | |
Memory price | $0.0042370 | 11.82% | $0.0010300 | 11.87% |
CPU vs. memory in memory optimized machines
Next, the same was done for memory optimized machines with predefined memory and vCPUs.
Machine type | Predefined | On-demand | Spot | ||
---|---|---|---|---|---|
M2 | In $ terms | Percentage | In $ terms | Percentage | |
Total price | $0.0399000 | $0.0084100 | |||
vCPU price | $0.0348000 | 87.22% | $0.0073300 | 87.16% | |
Memory price | $0.0051000 | 12.78% | $0.0010800 | 12.84% |
Estimating CPU vs. memory costs in AWS
Based on GCP pricing, the CPU vs. RAM ratio is around 88% to 12%.
The formula used for the calculation is as follows:
instancePricePerHour / ((cpu_count X cpu_ratio) + (ram_gib X ram_ratio)) X resource_ratio
Here is how it works on the example of an r5.large instance:
CPU: 0.126 / ( (2 X 88) + (16 X 12) ) X 88 == 0.0301
RAM: 0.126 / ( (2 X 88) + (16 X 12) ) X 12 == 0.0041
The result was estimated based on the price distribution between CPU and memory prices. Using these ratios, AWS compute costs divided into CPU and memory could be estimated
Here are two tables depicting estimated prices for AWS general purpose and memory optimized machines.
General purpose (on-demand)
Instance | Hourly price | vCPUs | Memory | vCPU price based on GCP (per vCPU hour) | Memory price based on GCP (per GB hour) |
---|---|---|---|---|---|
c5.large | $0.08500 | 2 | 4 | $0.03352 | $0.00449 |
c5.xlarge | $0.17000 | 4 | 8 | $0.03352 | $0.00449 |
c5.2xlarge | $0.34000 | 8 | 16 | $0.03352 | $0.00449 |
c4.large | $0.10000 | 2 | 3.75 | $0.03996 | $0.00536 |
c4.xlarge | $0.19900 | 4 | 7.5 | $0.03976 | $0.00533 |
c4.8xlarge | $1.59100 | 36 | 60 | $0.03613 | $0.00484 |
Memory-optimized (on-demand)
Instance | Hourly price | vCPUs | Memory | vCPU price based on GCP (per vCPU hour) | Memory price based on GCP (per GB hour) |
---|---|---|---|---|---|
r5.large | $0.12600 | 2 | 16 | $0.02900 | $0.00425 |
r5.xlarge | $0.25200 | 4 | 32 | $0.02900 | $0.00425 |
r5.2xlarge | $0.50400 | 8 | 64 | $0.02900 | $0.00425 |
r5.4xlarge | $1.00800 | 16 | 128 | $0.02900 | $0.00425 |
r5.8xlarge | $2.01600 | 32 | 256 | $0.02900 | $0.00425 |
Eventually, the CPU/memory ratio of 88-12 was implemented into CAST AI.
Where to check CPU vs. memory cost in the CAST AI cost monitoring dashboard
To see the breakdown of compute cost into CPU and memory, head over to the the cost monitoring module and click on the cluster or workloads report.
Here is an example of the Workloads report stating the average requests and costs per resource:
Summary
To increase the accuracy of the CAST AI cost monitoring tool, CAST AI shows compute costs divided into CPU and memory for AWS and Azure. You can get more accurate cost monitoring data, understand what you're paying for, and see costs broken down by workloads, namespaces, and labels.
Updated 12 months ago