EC2 Spot Instances

  • Can get a discount of up to 90% compared to On-demand

  • Instances that you can “lose” at any point of time if your max price is less than the current spot price

  • The MOST cost-efficient instances in AWS

  • Useful for workloads that are resilient to failure

    • Batch jobs

    • Data analysis

    • Image processing

    • Any distributed workloads

    • Workloads with a flexible start and end time

  • Not suitable for critical jobs or databases.

EC2 Spot Instance Requests

  • Can get a discount of up to 90% compared to On-demand.

  • Define max spot price and get the instance while current spot price < max.

    • The hourly spot price varies based on offer and capacity.

    • If the current spot price > your max price you can choose to stop or terminate your instance with a 2 minute grace period.

  • Other strategy: Spot Block

    • “block” spot instance during a specified time frame (1 to 6 hours) without interruptions

    • In rare situations, the instance may be reclaimed.

  • Used for batch jobs, data analysis, or workloads that are resilient to failures.

  • Not great for critical jobs or databases.

Terminating Spot Instances

You can only cancel Spot Instance requests that are open, active, or disabled. Cancelling a Spot Request does not terminate instances You must first cancel a Spot Request, and then terminate the associated Spot Instances

Spot Instance Lifecycle

Spot Fleets

  • Spot Fleets = set of Spot Instances + (optional) On-Demand Instances

  • The Spot Fleet will try to meet the target capacity with price constraints

    • Define possible launch pools: instance type (m5.large), OS, Availability Zone

    • Can have multiple launch pools, so that the fleet can choose

    • Spot Fleet stops launching instances when reaching capacity or max cost

  • Strategies to allocate Spot Instances:

    • lowestPrice: from the pool with the lowest price (cost optimization, short workload)

    • diversified: distributed across all pools (great for availability, long workloads)

    • capacityOptimized: pool with the optimal capacity for the number of instances

  • Spot Fleets allow us to automatically request Spot Instances with the lowest price

Last updated