Scalable and Resilient Architectures: Scaling, Balancing, and Caching
Identifying and implementing appropriate auto scaling, load balancing, and caching solutions
Scalable and Resilient Architectures: Scaling, Balancing, and Caching
This study guide focuses on Domain 3 of the AWS Certified DevOps Engineer - Professional (DOP-C02) exam, specifically regarding the implementation of solutions that scale to meet business requirements while ensuring high availability through load balancing and caching.
Learning Objectives
By the end of this module, you should be able to:
- Translate business resiliency requirements into technical AWS architectures.
- Implement appropriate Auto Scaling policies using both standard and custom metrics.
- Configure Elastic Load Balancing (ELB) to support cross-AZ and cross-Region resiliency.
- Identify single points of failure (SPOFs) and remediate them using distributed architectures.
- Optimize performance and cost using caching solutions like Amazon CloudFront and ElastiCache.
Key Terms & Glossary
- Horizontal Scaling: Adding more instances to a resource pool (scaling out) rather than increasing the power of a single instance (scaling up).
- Target Tracking Policy: A scaling policy that increases or decreases the current capacity of a group based on a target value for a specific metric (e.g., maintain average CPU at 50%).
- Cooldown Period: A configurable setting for Auto Scaling that ensures the group does not launch or terminate additional instances before the previous scaling activity takes effect.
- Sticky Sessions (Session Affinity): A load balancer feature that binds a user's session to a specific target instance for the duration of the session.
- RTO (Recovery Time Objective): The maximum acceptable delay between the interruption of service and restoration of service.
- RPO (Recovery Point Objective): The maximum acceptable amount of data loss measured in time.
The "Big Idea"
Resiliency is the ability of an application to resist or recover from hardware or software failure. In the AWS ecosystem, this is achieved by moving away from monolithic, "fragile" systems toward loosely coupled, distributed architectures. By combining Auto Scaling (to handle volume), Load Balancing (to ensure health and distribution), and Caching (to reduce latency and origin load), you create a system that can self-heal and grow dynamically without manual intervention.
Formula / Concept Box
| Concept | Metric / Formula / Rule |
|---|---|
| Scaling Metric Choice | Use CPUUtilization for compute-heavy, RequestCountPerTarget for web-heavy, and ApproximateNumberOfMessagesVisible for worker-heavy (SQS) workloads. |
| ASG Health Check Grace Period | Time to initialize + Time to pass health check. Setting this too low causes "thrashing" (terminating instances before they are ready). |
| Cache Hit Ratio (CHR) | . Higher CHR reduces costs and origin load. |
Hierarchical Outline
- Auto Scaling Strategies
- Scaling Policies: Target Tracking (recommended), Step Scaling (for aggressive response), and Scheduled Scaling (for predictable patterns).
- Custom Metrics: Using the CloudWatch Agent to scale on Memory utilization or disk space (not available by default).
- Lifecycle Hooks: Pausing instances during launch or termination to perform software installation or data backup.
- Load Balancing Architecture
- Application Load Balancer (ALB): Layer 7; supports path-based and host-based routing; ideal for microservices/containers.
- Network Load Balancer (NLB): Layer 4; ultra-high performance; static IP support; ideal for TCP/UDP traffic.
- Health Checks: Differentiating between EC2 status checks (hardware) and ELB health checks (application layer response).
- Caching and Data Distribution
- Edge Caching: Using CloudFront to cache static and dynamic content globally.
- Database Caching: Implementing ElastiCache (Redis/Memcached) to offload read pressure from RDS.
- Global Resiliency: Using Route 53 (Failover/Latency routing) and DynamoDB Global Tables.
Visual Anchors
Auto Scaling Decision Flow
Multi-Region Resilient Architecture
Definition-Example Pairs
- Loose Coupling: An architecture where components have little or no knowledge of the definitions of other separate components.
- Example: Using an SQS queue between a frontend web server and a backend image processor so the frontend doesn't break if the backend is down.
- Vertical Scaling: Increasing the capacity of an existing resource.
- Example: Changing an EC2 instance type from
t3.mediumtom5.largeduring a maintenance window.
- Example: Changing an EC2 instance type from
- Pilot Light: A DR strategy where a minimal version of an environment is always running in another region.
- Example: Keeping an RDS Read Replica in a secondary region, but only launching the EC2 application fleet when a disaster occurs.
Worked Examples
Example 1: Scaling based on SQS Queue Depth
Problem: A video processing application is falling behind on jobs. Standard CPU scaling isn't working because the processing is I/O bound. Solution:
- Identify the metric
ApproximateNumberOfMessagesVisiblein SQS. - Create a Custom Metric in CloudWatch called
BacklogPerInstance(Queue Depth / Number of Instances in ASG). - Configure a Target Tracking Policy in the Auto Scaling Group to keep
BacklogPerInstanceat 10. - Result: As the queue grows, the ASG scales out proportionally to the workload, regardless of CPU usage.
Example 2: Eliminating SPOF in a Web Tier
Problem: A legacy application runs on a single large EC2 instance with an Elastic IP. Solution:
- Create an Amazon Machine Image (AMI) of the instance.
- Create a Launch Template using that AMI.
- Deploy an ALB across three Availability Zones.
- Create an ASG with a minimum capacity of 2 across two AZs.
- Update DNS to point to the ALB's DNS name instead of the Elastic IP.
Checkpoint Questions
- What is the main difference between an ASG health check and an ELB health check?
- Why would a DevOps engineer use a "Step Scaling" policy instead of "Target Tracking"?
- Which load balancer should be used for a legacy application that requires fixed IP addresses for its clients?
- How does CloudFront improve resiliency for the origin server during a traffic spike?
▶Click to see answers
- ASG health checks focus on instance state (running/impaired); ELB health checks test the application responsiveness (e.g., HTTP 200 OK).
- Step scaling allows for different scaling increments based on the size of the breach (e.g., add 1 instance at 60% CPU, but add 4 instances at 90% CPU).
- Network Load Balancer (NLB), as it supports Elastic IPs.
- By serving cached content from the edge, it reduces the number of requests that reach the origin (request collapsing and offloading).
Muddy Points & Cross-Refs
- Cooldown vs. Warm-up: The Cooldown (Default 300s) happens AFTER a scaling activity to let the metric stabilize. Warm-up is part of a Target Tracking policy and dictates how long an instance needs before it contributes to the group's metrics.
- Cross-Zone Load Balancing: In ALB, this is always on. In NLB, it is off by default. If off, each load balancer node only distributes traffic to targets in its own AZ.
- Deep Dive: For more on automating the CloudWatch agent, see the Configuration Management module.
Comparison Tables
Load Balancer Selection
| Feature | Application (ALB) | Network (NLB) |
|---|---|---|
| Layer | 7 (HTTP/HTTPS) | 4 (TCP/UDP/TLS) |
| Static IP | No (DNS only) | Yes (Elastic IP) |
| Latency | Low | Ultra-low (Microseconds) |
| Routing Rules | Path, Host, Query String | IP Protocol, Port |
| WAF Integration | Yes | No |
Caching Strategies
| Solution | Best For | Typical Latency |
|---|---|---|
| CloudFront | Global static/dynamic content | ~10-100ms |
| ElastiCache | Database query results / Sessions | < 1ms |
| DAX | DynamoDB specific read-heavy apps | Microseconds |
| S3 Replication | Cross-region data availability | Minutes |