Skip to main content
Containers

Run Containers Without Wasting Money: A Blunt Guide to Compute Choices

Containers are easy; the compute bill is not. Here's how to pick between EC2, Fargate, EKS, and Spot instances without burning cash.

Who This Is For

Imagine you're staring at a cloud bill that's twice what you expected. You containerized everything—good for you—but now the compute bill is eating your lunch. This is for the engineer or tech lead who has a working Kubernetes cluster or a Docker Compose setup and wants to cut costs without rewriting the architecture. You're not a beginner; you know your way around a terminal. But you need a pragmatic, opinionated walkthrough of the compute options that actually matter for containers. Let's get to it.

Step 1: Stop Paying On-Demand for Steady Workloads

First, audit what you're running. If your containers run 24/7—like a web service or a database—you're probably paying On-Demand prices. That's the most expensive way to buy compute, and you're leaving money on the table. AWS Savings Plans can cut your bill by up to 72% compared to On-Demand (AWS EC2 Pricing). That's not a rounding error; that's a real discount. For a steady workload, commit to a 1- or 3-year Savings Plan and watch the savings pile up. But don't commit blindly. Use AWS Compute Optimizer (AWS Compute Optimizer) to find idle resources and rightsizing opportunities. It'll flag unattached EBS volumes and idle instances, and it can even tell you if migrating to Graviton—AWS's ARM-based chips—would save you more. Graviton instances cost up to 20% less than comparable x86 instances (AWS Graviton). That's a no-brainer for steady-state.

Step 2: Use Spot for Anything That Can Tolerate a Kick

Now, for the workloads that can handle interruption—batch jobs, CI/CD, dev/test—stop paying full price. Spot instances are the way. AWS gives you up to a 90% discount on unused capacity (AWS EC2 Spot). Azure and Google offer similar deals. Azure Spot VMs give you a significant saving but can evict you with 30 seconds' notice (Azure Spot VMs). Google Cloud Spot VMs are up to 91% cheaper and give you at least a 60% discount, with a 30-second preemption warning (Google Cloud Spot VMs). The catch: you need to design for it. If your container app is stateless and fault-tolerant, you're golden. If it's not, you'll lose work. So, make your containers resumable, and you can run a whole fleet on Spot for pennies. For example, a t3.micro On-Demand in us-east-1 costs $0.0104/hour (AWS EC2 Price List API). At 90% off, that's about $0.001/hour. You could run a hundred of those for the price of a coffee.

Step 3: Choose the Right Container Platform—Don't Just Default to Kubernetes

Kubernetes is the de facto standard—82% of container users run it in production (CNCF Annual Cloud Native Survey). But managed Kubernetes comes with overhead. If you're on AWS, you have a choice: ECS or EKS. EKS is a managed Kubernetes service, but you pay for the control plane (AWS EKS). ECS, on the other hand, is a fully managed container service that can be simpler and cheaper for many workloads (AWS ECS). If you don't need Kubernetes' full flexibility, ECS might save you money and headaches. And if you want to skip the cluster management entirely, consider serverless. AWS Fargate runs containers without managing servers, and it scales to 16 vCPU and 120 GB per task (AWS Fargate). It's pay-as-you-go, but you pay a premium for the convenience. For a small, spiky workload, Fargate can be a win. But for a steady, high-volume workload, you'll likely pay more than with EC2 plus a Savings Plan. So, do the math.

Step 4: Don't Forget the Free Tiers—They're Not Just for Startups

You might think free tiers are only for new accounts, but they can also work for low-traffic side projects or dev environments. AWS Free Tier includes one million Lambda requests and 400,000 GB-seconds per month (AWS Lambda Pricing). Azure Functions gives you a million requests and 400,000 GB-seconds free each month (Azure Functions Pricing). Google Cloud Functions offers 2 million invocations and 400,000 GB-seconds (Google Cloud Functions Pricing). If your container workload can be broken into functions, you might run it for free. But beware: free tiers have limits, and if you exceed them, the bill can spike. So, set up billing alerts and monitor usage. Also, don't forget that Azure Container Apps has an always-free tier of 180,000 vCPU-seconds and 2 million requests per month (Azure Free Account). That's a great way to run a small containerized microservice without paying a cent.

What Can Go Wrong

Here's the trap: you commit to a Savings Plan or a Reserved Instance, and then your workload changes. You bought a 3-year commitment for a specific instance family, and now you need GPUs for AI. You're stuck with a discount you can't use. That's why you should consider Compute Savings Plans, which apply automatically to any instance family, region, or OS (AWS Savings Plans). They're more flexible than EC2 Instance Savings Plans, though they might offer a slightly lower discount. Also, Spot instances can be reclaimed at any time. If your job is long-running and not checkpointed, you'll lose progress. So, always design for interruption. And don't forget: per-second billing means you're charged for every second you use, so don't leave instances running overnight by mistake (AWS EC2 Pricing).

The Single Most Important Thing

Match your compute to your workload's tolerance for interruption and your willingness to commit. Use On-Demand for unpredictable, critical workloads; Savings Plans or Reserved Instances for steady, predictable ones; and Spot for the rest. That's the whole game.

Sources

  • AWS EC2 Pricing - https://aws.amazon.com/ec2/pricing/
  • AWS EC2 Spot - https://aws.amazon.com/ec2/spot/
  • AWS Fargate - https://aws.amazon.com/fargate/
  • AWS Lambda Pricing - https://aws.amazon.com/lambda/pricing/
  • Azure Functions Pricing - https://azure.microsoft.com/en-us/pricing/details/functions/
  • Google Cloud Functions Pricing - https://www.srvrlss.io/provider/google-cloud-functions/

Share this article:

Comments (0)

No comments yet. Be the first to comment!