Phase 5: Platform Engineering

Right-sizing, reserved instances & spot/preemptible workloads

Intermediate ~2 min read
Think of it this way A friendly analogy. Read this if the technical version feels dense. Show Hide

Imagine you’re hosting a super fun board game night for all your friends! You want to make sure everyone has a comfy chair, a spot at a table, and yummy snacks. Let’s say you could have up to 10 friends, but usually only 5 or 6 show up. If you always set out 10 chairs, 3 tables, and pizza for 10, even when only 5 friends show, you’d waste a lot of space and food! Right-sizing is like being a smart party planner. You check how many friends actually came and then only set out what's needed for them. If more friends suddenly arrive, you quickly grab extra chairs from the closet. This way, you’re not wasteful, and everyone still has a great time without using more than you need.

Sometimes, though, you know for sure certain friends will always be there. Let’s say your best friend, Alex, comes to every single game night without fail, week after week. For someone so reliable, you might make a special deal. This is like Reserved Instances. You could tell your parents, "Alex is always here, so can we reserve that comfy beanbag chair and a permanent spot at the main table for Alex for the next year?" Because you’re committing to using that spot for Alex for a long time, your parents might give you a special discount – maybe you don't have to clean that specific area every time, or they'll buy Alex's favorite snack in bulk for cheaper. It’s a great way to save money on things you know you’ll use consistently.

Then there are special situations, like when your cousin is visiting for just one evening, or an old friend is passing through. They might join your game night if there’s an extra space available and if no one else needs it. This is like using a Spot chair (sometimes called Preemptible). Your parents might say, "You can borrow this folding chair from the garage, but if we need it for Aunt Carol's bridge club tomorrow, you'll have to put it back with very short notice." You get to use the chair for free or super cheap, but you have to be ready to give it up quickly. You wouldn’t use this for Alex, who needs a guaranteed spot, but it’s perfect for temporary guests or quick games where it’s okay if a player sometimes has to leave.

So, when you manage computers and their jobs, it’s a lot like being this clever game night host. By making smart choices about how many computer "chairs" and "tables" you set out, reserving long-term spots for your "best friends," and using super cheap temporary spots for "surprise guests," you make sure everything runs smoothly and efficiently. This means you can run your computer systems without spending too much money or wasting valuable resources.

Effective cost management for Site Reliability Engineers involves strategically optimizing cloud resource expenditure without compromising reliability or performance. A fundamental pillar is Right-sizing, which means continuously evaluating your compute resources (CPU, memory, disk I/O) against actual workload utilization. Rather than over-provisioning for peak load 100% of the time, SREs should leverage monitoring tools and cloud provider recommendations to identify idle or underutilized instances and scale them down or terminate them. Implementing auto-scaling groups also ensures resources dynamically match demand, eliminating waste during low utilization periods and preventing performance bottlenecks during spikes, directly impacting your bottom line.

For stable, predictable workloads that run consistently, Reserved Instances (RIs) or their more flexible counterparts, Savings Plans, offer substantial cost reductions. Cloud providers offer significant discounts (often 50-75%) in exchange for a one or three-year commitment to a specific instance type, region, or compute spend. SREs play a crucial role in forecasting base infrastructure needs for services like databases, core APIs, or always-on batch processors. By purchasing RIs or Savings Plans for this baseline capacity, you lock in lower rates, transforming variable on-demand costs into predictable, discounted expenses, provided the committed resources are fully utilized.

Finally, Spot Instances (AWS) or Preemptible VMs (GCP) present an opportunity for massive savings, sometimes up to 90% off on-demand prices. These leverage unused cloud provider capacity, but come with the caveat that the provider can reclaim them with short notice. SREs can harness this cost-effectiveness for fault-tolerant, stateless, or interruptible workloads such as batch processing jobs, containerized microservices running on Kubernetes nodes, rendering farms, or dev/test environments. Architecting applications to gracefully handle interruptions and resume work is key to successfully integrating spot/preemptible workloads into your infrastructure, optimizing costs for suitable tasks.

Key Takeaways

  • Right-sizing: Continuously adjust resources to actual usage to eliminate waste and save on immediate compute costs.
  • Reserved Instances/Savings Plans: Secure significant discounts by committing to predictable, stable infrastructure needs.
  • Spot/Preemptible Workloads: Achieve deep cost savings for fault-tolerant, interruptible tasks by utilizing unused cloud capacity.
  • Strategic Mix: Combine all three approaches (right-sizing, RIs, spot) for a comprehensive and optimized cloud cost strategy.

Code Example

bash
aws ec2 describe-instances \
  --query 'Reservations[*].Instances[*].[InstanceId, InstanceType, State.Name, PublicIpAddress]' \
  --filters "Name=instance-state-name,Values=running" \
  --output table

How this code works

This command's primary job is to provide a clear summary of all currently running EC2 instances, a crucial first step in assessing an AWS environment for right-sizing opportunities and identifying potential candidates for cost-saving measures like reserved or spot instances. It works by asking AWS for information about EC2 instances and then carefully selecting and formatting only the most relevant details.

The aws ec2 describe-instances command initiates the data retrieval. Critically, the --filters option refines this immediately, ensuring only instances with an instance-state-name of running are considered; this avoids listing resources that are not actively incurring compute costs. Next, the --query option uses JMESPath to navigate the complex raw data, specifically drilling into Reservations[*].Instances[*] to extract an instance's InstanceId, InstanceType, current State.Name, and PublicIpAddress. A subtle but important detail is specifying State.Name instead of just State, as State itself is an object, not the desired string value. Finally, --output table transforms the results into a human-readable table, making it easy to digest the information quickly for cost management analysis.