awsec2cost-optimizationright-sizing

EC2 compute-optimized vs general-purpose cost: C-family or M-family

The C-family (compute-optimized) gives more CPU per dollar with less memory, while the M-family (general-purpose) balances CPU and memory at a higher price. Picking the wrong one wastes money on RAM you do not use or forces oversizing to get enough CPU. Here is how to choose on cost.

The C3X Team··6 min read

Quick answer

The C-family (compute-optimized, such as C7g and C7i) offers a 1:2 vCPU-to-GB memory ratio and the lowest price per vCPU, while the M-family (general-purpose, M7g and M7i) offers a 1:4 ratio at a higher price for the extra memory. For CPU-heavy workloads with modest memory needs, the C-family is cheaper because you are not paying for RAM you do not use. For balanced workloads that need the memory, the M-family avoids having to oversize a C-instance just to get enough memory. The choice hinges on your actual CPU-to-memory ratio: match the family to it and you stop paying for the resource you are not consuming.

Two of the most-used EC2 families are the C-series (compute-optimized) and the M-series (general-purpose). They look similar and often cost only a little apart per hour, but they package CPU and memory in different ratios, and that ratio is what determines which one is cheaper for a given workload. Choosing on family name rather than on your resource profile is a common and quiet source of waste.

The core difference: memory per core

FamilyvCPU-to-GB ratioExample (large)Approx hourly
C-family (compute)1:2c7g.large: 2 vCPU, 4 GB~$0.0725
M-family (general)1:4m7g.large: 2 vCPU, 8 GB~$0.0816
R-family (memory)1:8r7g.large: 2 vCPU, 16 GB~$0.1071

A c7g.large gives 2 vCPUs and 4 GB of memory for about $0.0725 per hour. An m7g.large gives the same 2 vCPUs but 8 GB of memory for about $0.0816. The M-instance costs more because you are paying for twice the RAM. If your workload uses the CPU hard but only needs 3 GB of memory, the extra 4 GB on the M-instance is money spent on nothing.

When compute-optimized is cheaper

CPU-bound workloads with modest memory footprints are the C-family's home: batch processing, video encoding, high-throughput web and API servers, scientific computing, and game servers. For these, the C-family delivers the CPU you need at the lowest price per vCPU, and the smaller memory allocation is not a constraint. Running them on M-instances means paying the memory premium on every instance, every hour, for RAM that sits idle.

When general-purpose is cheaper

The trap runs the other way too. If a workload genuinely needs 8 GB of memory per 2 vCPUs, forcing it onto the C-family means buying a bigger C-instance (say c7g.xlarge with 4 vCPUs and 8 GB) just to reach the memory, which then overpays for CPU. In that case the M-family's balanced ratio is cheaper because it matches the workload without oversizing. General-purpose exists precisely for workloads whose CPU and memory needs are roughly balanced.

And if memory dominates, neither is right: the R-family (memory-optimized, 1:8 ratio) is the cheaper answer, covered in the memory-optimized guide. The families are tools for different ratios, not a quality ladder.

How to pick on cost

Measure your workload's real CPU and memory use, then compute the ratio. If you use far more CPU than memory, the C-family is cheaper. If the two are balanced near 1:4, the M-family fits without oversizing. If memory leads, look at the R-family. The goal is to buy the family whose ratio matches your consumption so you are not paying for the resource you leave idle, the same discipline as right-sizing the instance size itself. Both Graviton (C7g, M7g) and Intel (C7i, M7i) versions exist, and Graviton is roughly 20 percent cheaper either way. Price the candidate families against the resource catalog so the ratio decision is a concrete cost before you deploy.

FAQ

What is the difference between compute-optimized and general-purpose EC2?

Compute-optimized (C-family, such as C7g and C7i) provides a 1:2 vCPU-to-GB memory ratio and the lowest price per vCPU, while general-purpose (M-family, M7g and M7i) provides a 1:4 ratio at a higher price for the extra memory. The C-family suits CPU-heavy workloads with modest memory needs; the M-family suits balanced workloads that need the additional RAM.

Is the C-family cheaper than the M-family?

Per vCPU, yes: a c7g.large costs about $0.0725 per hour versus about $0.0816 for an m7g.large with the same 2 vCPUs but twice the memory. So for CPU-bound workloads with modest memory needs, the C-family is cheaper because you avoid paying for RAM you do not use. For workloads that genuinely need the memory, the M-family is cheaper because it avoids oversizing a C-instance to reach the required memory.

When should I use general-purpose instead of compute-optimized?

When your workload's CPU and memory needs are roughly balanced near a 1:4 ratio, so that fitting it onto a compute-optimized instance would force you to buy a larger C-instance just to reach the memory, overpaying for CPU. The M-family's balanced ratio matches these workloads without oversizing, making it the cheaper choice despite its higher per-vCPU price.

How do I know which EC2 family is cheapest for my workload?

Measure your workload's real CPU and memory use and compute the ratio. Far more CPU than memory points to the compute-optimized C-family; a balanced 1:4 ratio points to the general-purpose M-family; memory-dominant points to the memory-optimized R-family. Matching the family's ratio to your actual consumption ensures you are not paying for the resource you leave idle.

How does C3X help choose an EC2 family?

C3X prices your EC2 instances from Terraform against a live catalog, so you can compare a compute-optimized and a general-purpose configuration for the same workload before you deploy. That surfaces the memory premium of the M-family and the oversizing risk of the C-family as concrete monthly numbers in the pull request, so you pick the family whose ratio matches your workload.

What to do next

Match the EC2 family to your workload before you pay for idle memory. C3X reads your Terraform and prices your resources against a live catalog. Start with the quickstart.

Try C3X on your own Terraform

Free and open source. No API key required. One command to install, one command to estimate.