Introduction

Compute is typically the largest line item on an AWS invoice, yet most teams never treat it as a design choice. An engineer selects an x86 On-Demand instance during early development, adds "some headroom," and that same configuration often survives for years. By the time the bill arrives, the die is already cast. You cannot optimize this from a billing dashboard because the real decisions happen during architecture: which instance family you choose, how you purchase capacity, how your load balancer reacts when a node disappears, and where your containers persist data.

What Happened

The pattern is familiar. A team launches on general-purpose instances, sizes them generously, and never revisits the choice. Meanwhile, compute spend keeps climbing. The article breaks this down into four levers that determine both cost and resilience: hardware class, purchasing model, load balancer behavior under node loss, and data placement. It then walks through each one and concludes with an AWS CDK example that assembles a cost-optimized ECS cluster.

Why This Matters

Instance class sets the ratio of virtual CPUs to memory, which is usually more important than raw size. General-purpose M and T instances offer roughly one vCPU per four gibibytes of memory, suiting web servers and mixed workloads. Compute-optimized C instances provide about one vCPU per two gibibytes, fitting CPU-heavy APIs and batch jobs. Memory-optimized R and X instances deliver around one vCPU per eight gibibytes, ideal for caches and large heaps. Storage-optimized I and D instances bring local NVMe for high random IOPS, while accelerated G, P, Inf, and Trn instances handle GPUs and machine-learning chips.

Matching the class to your actual bottleneck prevents paying for idle resources. A CPU-bound service on M instances wastes memory budget; a memory-bound service on C instances forces over-scaling. Profiling should come before selection. If your code avoids x86-only dependencies, Graviton processors such as m8g, c8g, and r8g are worth considering. Graviton4 is up to 30 percent faster than Graviton3, and Graviton instances typically cost about 20 percent less than comparable Intel or AMD options.

How you buy capacity is just as important as what you buy. On-Demand instances carry full price with no commitment, making them suitable for uncertain traffic. Reserved Instances can discount up to 72 percent for one- or three-year terms. Savings Plans commit to an hourly dollar amount; EC2 Instance Savings Plans lock to a family and region for up to 72 percent off, while Compute Savings Plans offer slightly less savings but apply across EC2, Fargate, and Lambda. Spot instances provide up to 90 percent off spare capacity with a two-minute reclamation notice. Spot is no longer an auction; interruptions usually happen because AWS needs the hardware for On-Demand or Reserved customers, not because prices spiked.

Key Takeaways

  • Profile your workload before choosing an instance family; match CPU, memory, storage, or acceleration to the real bottleneck.
  • Prefer Graviton-based instances when possible for better price-performance.
  • Cover steady baseline usage with a one-year Compute Savings Plan, then handle peaks with diversified Spot capacity.
  • Keep a small On-Demand buffer as a fallback when Spot capacity tightens.
  • Spread Spot across multiple instance types and Availability Zones to avoid correlated interruptions.
  • Use the price-capacity-optimized allocation strategy as a default for most production fleets.
  • Enable Spot instance draining and set ALB deregistration delay and container stop timeout to 60–90 seconds, well inside the two-minute Spot notice window.
  • Keep application data off local node storage; use EFS for shared, AZ-independent file systems.
  • Watch hidden networking costs such as cross-AZ traffic, NAT Gateway fees, and unattached public IPv4 addresses.

Conclusion

Reducing your EC2 bill is not an accounting exercise. It is an architecture exercise. Right-sizing instance families, defaulting to ARM-based Graviton, layering Savings Plans under Spot, draining nodes cleanly, and keeping state off the host all lower costs while making the system more resilient to failure. None of these steps is complicated alone, but together they turn cloud spend from a surprise into a deliberate design outcome.