AWS

AWS cost optimization: how to reduce AWS costs

AWS cost optimization means paying only for the capacity your work uses. To reduce AWS costs, stop idle instances, rightsize the rest and delete what nothing uses. Then fit EKS requests, EBS volumes and S3 storage classes to real use, and buy Savings Plans last, sized to what’s left.

See where your AWS cost goes

Start with tags. A tag is a key and a value on a resource, such as team and payments. Tag resources by cost center, application or owner, and you can track each one’s AWS cost across services.

A tag counts in cost reports only once you activate it as a cost allocation tag. That goes for the tags AWS generates and for your own. Activated tags can take up to 24 hours to appear.

Watch out. Only an organization’s management account, or a standalone account, can open the cost allocation tags manager where tags are activated.

Then filter AWS Cost Explorer by tag and sort by size. The cost allocation report lists untagged resources too, so the gaps are easy to find. Each large line points to a section below:

  • EC2: idle instances and rightsizing.
  • EBS: volumes larger than their data.
  • EKS: pod requests and the nodes they hold.
  • S3 and data transfer: storage classes and traffic paths.

Cost allocation tags explains how they work.

AWS cost optimization, one cost line at a time

Work down the lines in this order. Each fix shrinks what the next one has to cover, so commitments come last.

Cost lineWhat you pay forFirst fixWho helps
Running time: at least one minute per start, then by the second.
Stop idle instances, then rightsize the rest.
AWS Compute Optimizer flags them.
Each volume’s size, type and performance, even while its instance is stopped.
Move gp2 to gp3, then bring volumes back to their data.
Compute Optimizer covers volumes. Amoeba rightsizes data volumes.
In most clusters, mainly the EC2 instances the nodes run on.
Fit pod requests to real use, then let spare nodes go.
Karpenter or the Cluster Autoscaler removes nodes. Coral rebalances the cluster.
Storage by class, plus retrieval fees in the infrequent-access and Glacier classes.
Match each bucket’s class to how its data is read.
S3 Intelligent-Tiering moves objects for you.
Data out to the internet, and across Availability Zones and Regions.
Keep traffic close, and reach S3 through a gateway endpoint.
Your network design.
On-Demand rates, unless you commit or use Spot.
Buy last, sized to what the fixes leave.
Cost Explorer recommends a commitment.

EC2: stop idle instances, rightsize the rest

Stop or delete what nothing uses

A stopped EC2 instance isn’t charged for usage or data transfer. Its EBS volumes are still charged, and so is any Elastic IP address associated with it. Each start then costs at least one minute of usage, and after that you pay by the second.

Worked example. A development instance that’s needed 10 hours a day, Monday to Friday, runs 10 × 5 = 50 of the week’s 168 hours. Stopped for the other 118 (168 − 50), it carries no usage charge for about 70% of the week (118 ÷ 168).

Stopping an instance erases any data on its instance store volumes, so copy what you need first. Its EBS volumes and their data stay.

Rightsize with AWS Compute Optimizer

Rightsizing matches each instance’s type and size to what it really uses. AWS Compute Optimizer does the analysis once you opt in. For an EC2 instance, it reads the specifications and 14 days of Amazon CloudWatch metrics:

  • vCPUs, memory and storage;
  • CPU use;
  • network in and out;
  • disk reads and writes.

It then reports whether each resource is optimal, with its top 3 recommendations and graphs of projected use. It also identifies idle resources, so you can stop or delete them.

Rule of thumb. 14 days can miss a monthly peak, such as month-end batch jobs. Enhanced infrastructure metrics, a paid feature, extends the look-back to 93 days.

Compute Optimizer covers Auto Scaling groups and EBS volumes too. AWS instance families explains how to read a type name such as c7gn.xlarge.

EBS: you pay for the size, not the data

You pay for an EBS volume’s configuration: its size, type and performance. The data inside doesn’t change that, so a half-empty volume costs as much as a full one.

Amazon EBS Elastic Volumes changes a volume in three ways. On an instance that supports it, the volume stays attached and the instance keeps running:

  • increase its size;
  • change its type;
  • adjust its performance.

The change itself is free. You’re charged for the new configuration from the moment it starts.

A gp2 volume can move to gp3 this way. If you don’t set IOPS or throughput, EBS keeps the gp2 volume’s performance or the gp3 baseline, whichever is higher.

Elastic Volumes can’t make a volume smaller. To shrink one, you create a smaller volume and copy the data across, with rsync on Linux or robocopy on Windows.

Next steps:

EKS: requests decide how many nodes you pay for

On Amazon EKS, nodes are usually most of the cost. AWS’s EKS best practices guide says that in most clusters, the bulk of cost comes from the EC2 instances that run your containers.

Pod requests set the CPU and memory each container asks for. The guide says requests should match real use. When they’re too high, the capacity sits unused, and that’s a large factor in total cluster cost.

The guide ranks the fixes for cluster compute in this order:

  1. Right-size workloads.
  2. Reduce unused capacity.
  3. Optimize capacity types, such as Spot, and accelerators, such as GPUs.

Smaller requests leave room on some nodes. With autoscaling set up, Karpenter or the Cluster Autoscaler can then remove them. Restrictive Pod Disruption Budgets can stop both from scaling down, so check yours first.

Kubernetes cost optimization on AKS and EKS walks through both steps. The EKS pricing calculator shows what a node costs a month, and how to choose EKS instance types helps you pick the next ones.

S3: match the storage class to how data is read

New objects go to S3 Standard unless you choose another storage class. Choosing the class that fits each use case reduces what you pay to store the data.

When you don’t know the access pattern

S3 Intelligent-Tiering moves objects between tiers by how they’re read:

  • after 30 days without access, to the Infrequent Access tier;
  • after 90 days without access, to the Archive Instant Access tier;
  • between tiers again when the access pattern changes.

It has no retrieval fees, only a small monthly fee per object for monitoring. Objects under 128 KB aren’t monitored, and always stay in the Frequent Access tier.

When you know the data is cold

A lifecycle configuration can move objects from S3 Standard to S3 Standard-IA. Standard-IA suits objects over 128 KB that you keep for at least 30 days:

  • an object under 128 KB is charged as 128 KB;
  • an object deleted before 30 days is charged for 30;
  • reading data back pays a per-GB retrieval fee.

S3 Glacier Instant Retrieval and Flexible Retrieval have a 90-day minimum storage duration, and Glacier Deep Archive 180 days.

Data transfer: keep traffic close and off NAT gateways

AWS charges for data transfer by direction and distance. Its data transfer overview sets out the rules:

  • Data coming into AWS from the internet isn’t charged.
  • Data going out to the internet is charged per service, at rates set by the Region it leaves.
  • Data transfer within the same Availability Zone is free.
  • Traffic that crosses an Availability Zone or Region boundary typically pays a charge.

Two parts of a network change what you pay. A NAT gateway adds a data processing charge for every GB that passes through it. A gateway VPC endpoint reaches S3 and DynamoDB in the same Region without data transfer charges.

So send S3 and DynamoDB traffic through gateway endpoints, not a NAT gateway. Keep chatty services in one Availability Zone where your availability design allows. Copy data across Regions only when you need to.

Egress cost explains the charge for data that leaves the cloud.

Savings Plans and Spot: commit last

A Savings Plan commits you to a set amount of compute use per hour, for one or three years. In return, AWS says you can save up to 72% on compute. Two kinds cover EC2:

  • Compute Savings Plans apply regardless of instance family, size, OS, tenancy or Region, and to Fargate and Lambda too. AWS’s EKS guide puts them at up to 66% off EC2.
  • EC2 Instance Savings Plans go up to 72%, but commit you to one instance family in one Region.

Commit after the other fixes. AWS Cost Explorer shows a recommended commitment and your past usage, so wait until that usage comes from after your last change.

Spot Instances run on spare EC2 capacity at discounts of up to 90%. AWS can reclaim them with a 2-minute notice, so keep them for work that can stop.

Rule of thumb. AWS’s EKS guide splits capacity three ways:

  • a Savings Plan for everything under your minimum capacity;
  • Spot for capacity that won’t affect your app’s availability;
  • On-Demand for the rest.

Where Coral and Amoeba fit

Stopping, deleting and committing are changes you make now and then. EKS requests and EBS volumes drift as usage moves, so Zoorik builds a product for each.

Coral, for EKS

Coral rebalances Amazon EKS clusters. It sizes pod requests to real use, so fewer EC2 instances can carry the same work. It also empties spare instances one at a time.

Karpenter or the Cluster Autoscaler still adds instances when demand grows, and terminates the ones Coral empties. Coral never creates machines itself. With Karpenter, a rebalance can also move work onto cheaper EC2 instances.

Node optimization starts when you connect a cluster. Pod sizing waits until you switch on “Automatically optimize”.

EKS cost optimization with Coral

Amoeba, for EBS

Amoeba rightsizes the EBS data volumes of Windows and Linux EC2 instances, and never touches the root volume. It moves an instance’s data volumes onto one btrfs pool sized to your data, with room to grow. On AWS, the pool uses gp3.

The services that use the data mounts restart at the switch onto the pool. After that, Amoeba rightsizes the pool without any downtime.

It grows the pool before it fills, and shrinks it one volume at a time when your data goes down and stays down. So you pay for close to what you use.

EBS cost optimization with Amoeba

Both products are in early access. Neither changes instance types outside EKS, S3 storage classes, your network or your commitments.

Their savings figures leave out your discounts and Savings Plans. So check them against your own rates before you size a commitment.

The free assessment estimates what you could save on Kubernetes (AKS and EKS) or block storage on Azure and AWS. It’s read-only, runs in Cloud Shell or your terminal, and writes one PDF. It sends nothing to Zoorik.

Questions about AWS cost optimization

Where do you start to reduce AWS costs?

Start with cost allocation tags and the largest line in Cost Explorer. Then stop or delete what nothing uses, act on Compute Optimizer’s rightsizing, and fit EKS requests and EBS volumes to real use. Buy Savings Plans last.

Does a stopped EC2 instance still cost money?

Yes, for what it keeps. Usage and data transfer stop being charged, but its EBS volumes and any associated Elastic IP addresses are still charged.

Can an EBS volume shrink?

Not in place. Elastic Volumes can grow a volume or change its type, but can’t make it smaller. You copy the data to a smaller volume, or, for a data volume, let Amoeba move it onto a pool sized to your data.

Savings Plan or Spot: which should you use?

A Savings Plan suits steady usage you’ll keep for one or three years. Spot suits work that can stop, since AWS can reclaim it with a 2-minute notice. AWS’s EKS guide uses both, with On-Demand for the rest.

Does Zoorik replace Cost Explorer or AWS Compute Optimizer?

No. Cost Explorer shows your spend, and Compute Optimizer recommends sizes for you to apply. Coral and Amoeba make the changes themselves, on EKS requests and nodes and on EBS data volumes.

Find your own number

One line in your cloud console. One PDF report with your estimated saving at list price.

Estimate your saving

Talk to the builders

Thirty minutes with the people who build Coral and Amoeba.

Book a demo (opens in a new tab)

Or write to founders@zoorik.com