Thursday, April 24, 2025

AWS Spot Fleets & instance Purchase Options

 

A Spot Fleet is a collection of Spot Instances (and optionally On-Demand Instances) managed together. You define:

  • Target capacity (in vCPUs, instances, or custom units)
  • Multiple instance types and AZs (for flexibility)
  • Max price you're willing to pay
  • Allocation strategy (lowest price, capacity optimized, etc.)

Then AWS figures out how to best fulfill the request across different instance types and Availability Zones to meet twtech target capacity at the lowest cost.

Core Benefits:

  • Automatically diversifies across instance types & AZs.
  • Can combine Spot + On-Demand for resilience.
  • AWS manages rebalancing if Spot capacity changes.

 Key Config Options:

  • AllocationStrategy: Controls how AWS picks instances.
    • lowestPrice (cheap but might get interrupted)
    • capacityOptimized (less interruptions)
    • priceCapacityOptimized (balance)
  • TargetCapacityType: Units (instances, vCPUs, or custom)
  • InstanceInterruptionBehavior: Decide what happens on termination (stop, hibernate, terminate)

 Spot Fleet vs. EC2 Auto Scaling Group (ASG)

Feature

Spot Fleet

Auto Scaling Group (Mixed Instances)

Multi-instance flexibility

✅ Yes (many types)

✅ Yes

AZ balancing

✅ Yes

✅ Yes

Autoscaling

❌ Manual scaling (unless integrated)

✅ Native autoscaling

More control

✅ Fine-grained Spot strategies

🔄 Less granular, but simpler management

 Spot Fleet Use Cases

 1. Batch Processing

  • Big data (Hadoop, Spark, EMR)
  • Scientific computing
  • Media rendering or transcoding

 2. CI/CD Pipelines

  • Use Spot Fleets to run Jenkins/GitLab runners or build jobs cheaply.

3. Stateless Web App Backends

  • Combine Spot + On-Demand in a fleet to balance cost and availability.

 4. Data Analytics / Machine Learning

  • Training models or ETL jobs that can be restarted or checkpointed.

 5. Game Servers or Container Clusters

  • Fleet to power ECS, EKS, or even game server backend workers.

 Spot Fleet Pricing Control

  • Set MaxTotalPrice to cap overall cost.
  • Use CloudWatch to monitor usage + cost.
twtech insight:

A: twtech EC2 purchasing option for Spot Instances.

  • Biggest Discount: Spot Instances can offer up to 90% off compared to On-Demand prices.
  • Not Suitable for Critical Jobs: AWS can terminate Spot Instances at any time if it needs the capacity back, so they're risky for critical workloads like production databases or critical apps that must always stay up.

A: twtech uses Security Groups to control traffic in and out of EC2 instances.

  • Security Groups act like virtual firewalls at the instance level.
  • They control inbound and outbound traffic based on rules you define (like allowing SSH, HTTP,

C: twtech reserves an EC2 Reserved Instance for one year or three years.

  • 1-year term: Lower commitment, still good savings.
  • 3-year term: Bigger discount, better for long-term workloads.

D:  For High-Performance Computing (HPC) applications, twtech uses Compute-Optimized (C5/C6i/C7g) instances?

  • Hpc6id/Hpc7g: Specifically designed for HPC workloads like fluid dynamics, finite element analysis, etc.
  • Compute-Optimized (C5/C6i/C7g): Great if twtech needs high CPU performance at a lower cost for HPC tasks.

E: twtech uses  a Reserved Instance for an application its plans to run continuously for 1 year.

  • It gives twtech a big discount (up to 72% compared to On-Demand pricing).
  • Perfect for steady-state workloads where twtech know it'll need the server long-term.

F: The best way to handle EC2 User Data.

  • User Data lets twtech run scripts (like installing software, updating OS packages) automatically when a twtech-instance is launched for the first time.
  • You can add shell scripts, cloud-init directives, or commands during instance setup.

G: For a critical application that uses an in-memory database, twtech uses  a Memory-Optimized instance, specifically the R6i, R7i, or X2idn/X2iedn instance types.

  • R6i/R7i: Great for high-memory workloads like Redis, Memcached, or similar.
  • X2idn/X2iedn: Even larger memory and better price per GB if you need massive in-memory databases.

H: For a high-frequency OLTP (Online Transaction Processing) database with thousands of requests per second, twtech uses a Storage-Optimized instance like I4i if IOPS (input/output operations) are the biggest bottleneck.

  • I4i: Best if you need very fast storage performance (NVMe SSDs) with extremely high IOPS for databases like SQL Server, Oracle, etc.  

I:  A Security Group can be attached to multiple EC2 instances at the same time.

This makes it easier to manage access rules across a group of instances together.

J: The best EC2 purchasing option for is Dedicated Hosts.

  • Dedicated Hosts give twtech physical servers fully dedicated to use (not shared with other customers) — perfect for strict compliance needs.
  • This let twtech to use its own server-bound licenses (like Windows Server, SQL Server, Oracle) to save costs.

K: The key difference between Dedicated Hosts and Dedicated Instances lies in the level of control and visibility they provide over the physical server:

Dedicated Hosts:

  • Physical server visibility: twtech gets full visibility into the underlying physical server. This is useful if twtech needs to meet specific compliance or licensing requirements that depend on the physical cores and network sockets.
  • License management: twtech can bring its own server-bound licenses (e.g., Windows Server, SQL Server, Oracle) and allocate them based on physical cores and sockets.
  • More control: twtech can choose to place its instances on specific hosts and have full control over the host's resources.

Dedicated Instances:

  • Isolation, no physical visibility: twtech instances run on hardware dedicated to twtecj, but AWS manages the underlying physical hardware. twtech doesn't get visibility into the physical server (e.g., cores, network sockets).
  • No control over placement: Unlike Dedicated Hosts, twtech can't choose the exact physical server where its instances are launched. The underlying hardware is still isolated, but it’s not as customizable.

Summary:

  • Dedicated Hosts: Full visibility and control over the physical hardware, ideal for compliance and licensing.
  • Dedicated Instances: Instances are physically isolated but twtech doesn't have control over the hardware

L: The best EC2 purchasing option is Dedicated Hosts.

  • Dedicated Hosts provide twtech with visibility into the physical cores and underlying network socket of the server.
  • This option is ideal for applications where twtech needs to comply with vendor licensing based on physical hardware.  This advantage allows twtech to track and allocate physical cores and sockets for licensing purposes.

M: Spot Fleet is a set of Spot Instances and optionally On-Demand Instances.

  • Spot Fleet allows twtech to request a combination of Spot Instances and On-Demand Instances to meet specific application requirements (like availability and cost balance).
  • The fleet automatically adjusts the number of instances to maintain the target capacity.

No comments:

Post a Comment

Kubernetes Clusters | Upstream Vs Downstream.

  The terms "upstream" and "downstream" in the context of Kubernetes clusters often refer to the direction of code fl...