Phase 2: Core Cloud Services

Spot instances, reserved capacity & savings plans

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

Imagine you love building amazing things with LEGOs, but these aren't just any LEGOs; they're super powerful computer pieces that make your games run or help websites work. When you're just starting, you usually buy these pieces "On-Demand" – meaning you grab them whenever you need them, paying the full price. That's easy, but if you need a lot of them, or need them for a long time, it can get pretty expensive, just like buying brand new LEGO sets every single day.

Luckily, there are clever ways to get these computer LEGOs for much less money! One way is like borrowing blocks from a giant LEGO factory that sometimes has extra pieces lying around. These are called Spot instances. The factory will let you use these spare blocks for a super cheap price, maybe up to 90% off! The only catch is, if a big customer suddenly needs those specific blocks, the factory will ask for them back with a quick heads-up, like a two-minute warning. This is perfect for building things that don't mind pausing and restarting, like a giant LEGO car you're tinkering with, where it's okay if you have to stop and come back to it later, or an experiment that doesn't mind a brief interruption.

Another way to save big is by making a promise. This is like telling the LEGO store, "I know I'm going to need this exact type of LEGO brick, consistently, for a whole year (or even three years)." Because you're committing to using them for so long, they give you a huge discount, sometimes up to 75% off! These are like your Reserved Capacity pieces. This is great for building really important, steady structures that you know will always be there, like the main walls of your LEGO castle. There are also Savings Plans, which are even more flexible. Instead of promising exact bricks, you promise to spend a certain amount of money on any LEGO bricks over a year. So, you still get a big discount on whatever you end up buying, even if you change your mind about which specific bricks you need as your castle grows!

So, by understanding these different ways to get your computer LEGOs, you can build much bigger, more complex, and cooler projects without spending all your allowance. You get to choose the best deal for whatever you're trying to create, making sure you have exactly the right blocks at the best price!

As you transition from understanding basic EC2 operations to designing scalable, cost-optimized architectures, mastering different pricing models is crucial. Beyond standard On-Demand instances, AWS offers powerful options like Spot instances, Reserved Capacity, and Savings Plans to significantly reduce your compute costs. These aren't just 'discounts'; they represent strategic choices based on your workload's stability, flexibility, and fault tolerance requirements.

Spot instances allow you to bid for unused EC2 capacity, offering massive discounts—up to 90% off On-Demand pricing. The trade-off is that AWS can reclaim these instances with a two-minute warning if the capacity is needed elsewhere. This makes them ideal for fault-tolerant, flexible, and stateless workloads like batch processing, CI/CD pipelines, dev/test environments, or rendering farms, where occasional interruptions are acceptable. In contrast, Reserved Instances (RIs) offer significant discounts (up to 75%) for committing to a specific instance type, region, and operating system for a 1- or 3-year term. RIs are best suited for steady-state, predictable workloads that require guaranteed capacity and have consistent resource needs over the long term.

Savings Plans provide a more flexible discount model than RIs, allowing you to commit to a consistent amount of compute usage (e.g., $10/hour) for 1 or 3 years, rather than specific instance attributes. This commitment automatically applies the discounted rate across various EC2 instance families, regions, operating systems, and even other compute services like Fargate and Lambda. This flexibility makes Savings Plans generally preferred for modern, dynamic cloud environments where your compute needs might evolve, making them an excellent choice for broad compute cost optimization without the rigidness of RIs. Both RIs and Savings Plans require careful planning but offer substantial, predictable savings.

Key Takeaways

  • Spot Instances offer the highest savings (up to 90%) for flexible, fault-tolerant, and interruptible workloads.
  • Reserved Instances provide significant discounts and capacity reservation for stable, predictable, long-running workloads with fixed requirements.
  • Savings Plans offer flexible commitment-based discounts across diverse compute usage (EC2, Fargate, Lambda), generally favored over RIs for modern, evolving architectures.
  • All three models require foresight and commitment but deliver substantial cost reductions compared to On-Demand pricing.

Code Example

bash
aws ec2 run-instances \
    --image-id ami-0abcdef1234567890 \
    --instance-type t3.micro \
    --count 1 \
    --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=MySpotInstance}]' \
    --instance-market-options 'MarketType=spot,SpotOptions={InstanceInterruptionBehavior=terminate}' \
    --key-name MyKeyPair \
    --security-group-ids sg-0123456789abcdef0

How this code works

This command launches a virtual machine (an EC2 instance) on Amazon Web Services, specifically requesting a "Spot instance." Spot instances let users bid on unused EC2 capacity, often leading to significant cost savings compared to on-demand instances. The aws ec2 run-instances command is the core action. It specifies basic instance details: an operating system image via image-id, a small instance type t3.micro, and launches count 1 instance. The tag-specifications help organize and identify the instance later with a Name tag of "MySpotInstance".

The key part for Spot instances is instance-market-options. This tells AWS that the instance is not a standard On-Demand instance, with MarketType=spot explicitly declaring the request as a Spot instance. The SpotOptions refine this further. A crucial setting here is InstanceInterruptionBehavior=terminate. This dictates that if AWS needs to reclaim the capacity, the instance will be stopped and removed. Not explicitly setting this might default to stop for some instance types, which retains associated storage and could incur unexpected charges even when the instance isn't running. Finally, key-name and security-group-ids are standard for secure access and network traffic control, enabling management of the virtual machine.