All guides
Practice now
D2 · Design for New Solutions

and scaling: ELB, Auto Scaling and advanced EC2

The SAP-C02 expects you to design complex high-availability architectures by correctly choosing between load balancer types, scaling policies and EC2 purchasing strategies to optimize cost and performance.

Icon-Architecture/48/Arch_Elastic-Load-Balancing_48

— ALB vs NLB vs GWLB

FeatureALB (Application)NLB (Network)GWLB (Gateway)
OSI LayerL7 — HTTP/HTTPS/gRPCL4 — TCP/UDP/TLSL3 — IP (all protocols)
RoutingPath, host, headers, query, HTTP methodIP:Port, TCP/UDP onlyN/A — appliance injection
LatencyMilliseconds (L7 processing overhead)Ultra-low (<1ms), L4 passthroughVariable depending on the appliance
Static IPsNo (uses DNS)Yes — static IP or Elastic IPNot applicable
WebSocketNative supportYes (TCP)Not applicable
gRPCNative supportNot nativeNot applicable
Preserves client IPX-Forwarded-For headerNative support (PROXY Protocol)Native support
Target TypesEC2, ECS, Lambda, IPEC2, ECS, IP (on-prem with PrivateLink)3rd-party security appliances
Main use caseHTTP microservices, advanced routing, APIsExtreme low latency, TCP/UDP, fixed IPsTraffic inspection with 3rd-party appliances

ALB — advanced features for the exam

Weighted Target GroupsDistributes traffic between target groups with weights. For blue/green or canary between app versions.
ALB Listener RulesUp to 100 rules per listener. Routes by path (/api/* → TG-API), host header (api.example.com → TG-API), query string, HTTP method, headers.
Lambda as TargetALB can route directly to Lambda functions. For serverless apps without API Gateway.
Sticky SessionsApplication-based cookies: the app defines the name. Duration-based: ALB creates the cookie. For apps with session state on EC2.

NLB — advanced features for the exam

Cross-Zone LBDistributes traffic evenly among instances across all AZs. Disabled by default on NLB (data transfer cost). Always enabled on ALB.
TLS TerminationNLB can terminate TLS (with an ACM cert) and pass HTTP to the backend. Or pass-through TLS to the backend for end-to-end encryption.
PrivateLinkNLB acts as an endpoint service for PrivateLink. The consumer creates an Interface VPC Endpoint that connects to the provider's NLB.
Preserve Source IPNLB passes the client's IP directly to the target (without modifying the packet). Critical for apps that need the real client IP.
Icon-Architecture/48/Arch_Amazon-EC2-Auto-Scaling_48

Advanced — policies and strategies

Scaling policy types

Simple Scaling

Adds/removes N instances when an alarm triggers. Has a cooldown period — won't scale again until it ends. Most basic option.

Step Scaling

Scales in steps based on alarm magnitude. e.g.: CPU 70-80% → +1 instance, CPU 80-90% → +2, CPU >90% → +3. No mandatory cooldown.

Target Tracking

Keeps a metric at a target value (e.g., 50% CPU). ASG scales up/down automatically. Smarter and simpler to configure.

Predictive Scaling

ML analyzes usage history and scales proactively before predictable spikes. Combines with Target Tracking for cyclical workloads.

Scheduled Scaling

Scales at specific times (e.g., +10 instances at 8am). For workloads that are predictable by time of day.

Advanced ASG configuration

Warm PoolPre-initializes instances in a stopped/running state. Cuts scale-out time by removing bootstrap time. For apps with slow initialization (Java, ML models).
Instance RefreshRolling update of ASG instances with a new Launch Template. Controls: minHealthyPercentage, checkpointPercentages for canary.
Lifecycle HooksPauses instance launch or termination to run custom actions (deregister from a service, flush logs, install agents).
Capacity RebalancingFor Spot: detects instances at risk of interruption and proactively launches replacements before the interruption occurs.
Mixed Instances PolicyCombines multiple instance types in the same ASG. Increases Spot availability. Configures instance type priorities.
Icon-Architecture/48/Arch_Amazon-EC2_48

Advanced — placement groups and purchasing options

Cluster Placement Group

Instances grouped on the SAME physical rack. Ultra-low network latency and maximum throughput between instances.

  • • 10 Gbps network between instances (vs 1 Gbps normal)
  • • < 1ms latency between instances in the group
  • → If the rack fails, every instance fails
  • → Not multi-AZ
  • → For HPC, GPU clusters, distributed ML training

Spread Placement Group

Instances spread across DIFFERENT racks (up to 7 instances per AZ). Maximum isolation from hardware failures.

  • • A rack failure only affects one instance
  • • Multi-AZ supported
  • • Maximum availability per instance
  • → Maximum 7 instances per AZ
  • → For critical applications with individual instances
  • → ZooKeeper, master databases, HAProxy

Partition Placement Group

Divides instances into partitions, each partition on a different rack. Up to 7 partitions per AZ, many instances per partition.

  • • Scales to hundreds of instances
  • • Fault isolation per partition
  • • The app knows which partition each instance is in
  • → For distributed workloads tolerant of rack failures
  • → HDFS, HBase, Cassandra, Kafka

EC2 purchasing options — for the professional architect

TypeDiscount vs On-DemandCommitmentBest for
On-DemandNo discount (base price)None — pay per secondUnpredictable workloads, dev/test, load testing
Reserved (Standard)Up to 72% with 3-year all-upfront1 or 3 years, fixed family/region/OSStable production with predictable 24/7 usage
Reserved (Convertible)Up to 54% with 3 years1 or 3 years, but you can change family/OSStable production but might change instance family
Savings Plans (Compute)Up to 66%1 or 3 years, $ per hour commitmentStable production, applies to EC2 + Fargate + Lambda
Savings Plans (EC2 Instance)Up to 72%1 or 3 years, fixed family in a regionProduction EC2 in a specific family/region
Spot InstancesUp to 90%None — can be interruptedBatch, CI/CD, ML training, tolerant stateless workloads
Dedicated Instances~10% more expensive than On-DemandNoneCompliance requiring dedicated (non-shared) hardware
Dedicated HostsMore expensive — you pay for the physical hostOn-Demand or Reserved (up to 70% discount)BYOL licenses (SQL Server, Oracle), strict compliance
Icon-Architecture/48/Arch_Amazon-EC2_48

Spot Fleet and EC2 Fleet — diversified capacity

Spot Fleet

Requests a mix of instance types and AZs to meet a target capacity. Maximizes Spot availability by diversifying across multiple pools.

Allocation Strategies
lowestPriceThe cheapest instances at that moment. Higher interruption risk.
diversifiedSpreads capacity across all specified pools. Higher availability.
capacityOptimizedChooses pools with more available capacity. Lower probability of interruption. Recommended.
priceCapacityOptimizedBalance between price and available capacity. Best overall option.

Spot Interruption — how to handle it

    Interruption Notice2-minute warning before interruption via instance metadata and EventBridge. The handler must persist state, drain connections and terminate cleanly.
    HibernationInstead of terminating, the instance hibernates — the RAM state is saved to EBS. When relaunched it picks up where it left off. For resumable workloads.
    ASG Capacity RebalancingASG launches a replacement instance before the interruption arrives. Requires enabling the option on the ASG.
    Spot with On-Demand baseConfigures a base percentage of On-Demand in the ASG and the rest Spot. Guarantees minimum capacity even if Spot isn't available.
Icon-Architecture/48/Arch_Amazon-EC2_48

Capacity Reservations and Dedicated Hosts

On-Demand Capacity Reservations

Reserves EC2 capacity in a specific AZ with no time commitment. Guarantees availability for critical launches (DR drills, planned traffic spikes).

  • • No discount — you always pay the On-Demand price (whether you use the instance or not)
  • • Combine with Savings Plans to apply a discount to usage
  • • Useful for DR: guarantees capacity will be available in the DR region when needed

Dedicated Hosts vs Dedicated Instances

Dedicated Instances

Instances on hardware dedicated to your account, but the physical server can change across restarts. You can't see or control host placement. Basic compliance.

Dedicated Hosts

An entire physical server dedicated to you. Visibility into socket and core counts. Placement control. Required for BYOL of Oracle, SQL Server, Windows Server (per-core/per-socket licensing).

Icon-Architecture/48/Arch_Elastic-Load-Balancing_48

Multi-AZ design — best practices for the professional architect

Multi-AZ design rules

  • Distribute ASG instances evenly across (e.g., 2 instances minimum per AZ)
  • ELB distributes traffic across AZs — enable cross-zone load balancing
  • Data in RDS Multi-AZ: standby in a different AZ, automatic failover
  • Public and private subnets in every AZ you use
  • : one per AZ (not a single NAT for all AZs)
  • ElastiCache with replicas across multiple AZs for HA

Common anti-patterns

  • A single NAT Gateway in us-east-1a: if that AZ fails, instances in us-east-1b lose internet access
  • EBS shared between instances in different AZs: EBS is zonal, it can't be attached cross-AZ
  • ASG with only one AZ: if that AZ fails, the ASG can't launch instances elsewhere
  • RDS without Multi-AZ in production: a hardware failure requires a manual restore from backup
  • Session state in EC2 memory without Sticky Sessions: a user may lose their session on the next request
Icon-Architecture/48/Arch_Amazon-EC2_48

Common exam traps

Trap: "Cluster Placement Group guarantees high availability"

Reality: FALSE. Cluster Placement Group maximizes network performance by grouping instances on the same rack — the opposite of HA. If the rack fails, every instance fails. For HA, use Spread Placement Group.

Trap: "Reserved Instances automatically apply to any EC2 instance"

Reality: Depends on the type. Standard Reserved Instances only apply to instances that match exactly (family, AZ, OS). Convertible RIs have more flexibility. Savings Plans Compute apply more broadly (EC2 + Fargate + Lambda).

Trap: "Dedicated Instances and Dedicated Hosts are equivalent"

Reality: They're different. Dedicated Instances guarantee there are no other tenants on the same physical server, but you don't control which server. Dedicated Hosts give you the specific physical server — required for BYOL that licenses per socket/core.

Trap: "ALB Cross-Zone Load Balancing has an extra cost"

Reality: ALB has Cross-Zone LB enabled by default and at NO extra cost. NLB has Cross-Zone LB disabled by default and incurs data transfer cost between AZs if enabled.

Did you get this topic?

Test what you just learned

A financial analysis firm runs 6-hour ML jobs that process historical data. The jobs can resume from checkpoints saved in S3 if interrupted. The team wants to minimize costs while keeping high availability to complete the jobs. What is the optimal EC2 configuration?

Ready to test "High Availability and Scaling: ELB, Auto Scaling and Advanced EC2"?

Put what you learned to the test with original SAP-C02 exam questions.

Start SAP-C02 mock exam

Unlimited mock exams with the Pro plan

Log in to track your progress.