1. Web Application Infrastructure (Layer 7 Load Balancing)
Use Case: Host a web application with HTTP/HTTPS traffic that auto-scales based on demand, with requests routed to instances across multiple AZs.
- Resources:
- VPC with subnets across multiple Availability Zones (AZs)
- Application Load Balancer (ALB) for Layer 7 (HTTP/HTTPS) routing
- Auto Scaling Group (ASG) with EC2 instances (could use Amazon Linux AMI)
- Security Groups for ALB and ASG
- Launch Template for ASG configuration
- Practice Goals:
- Set up an ALB to balance HTTP/HTTPS traffic across instances.
- Implement dynamic and scheduled scaling policies for the ASG.
- Configure HTTPS listeners and SSL certificates with AWS ACM (AWS Certificate Manager).
- Use health checks to remove unhealthy instances.
- CDK Implementation:
- Use
aws-cdk-lib.aws_ec2 for VPC, subnets, and security groups.
- Use
aws-cdk-lib.aws_autoscaling for the ASG and Launch Template.
- Use
aws-cdk-lib.aws_elasticloadbalancingv2 for ALB and target groups.
2. API Backend Service (Layer 4 Load Balancing)
Use Case: An API service that requires low-latency communication and high-speed connection handling, best suited for Network Load Balancer (NLB).
- Resources:
- VPC with both public and private subnets
- Network Load Balancer (NLB) for Layer 4 routing
- Auto Scaling Group with EC2 instances in private subnets (protected from public access)
- Security Groups for NLB and ASG
- Launch Template with Amazon Linux AMI optimized for high-speed networking
- Practice Goals:
- Configure an NLB to handle TCP traffic with low latency.
- Distribute traffic across private instances in the ASG using cross-zone load balancing.
- Test the setup with a mock API application that uses TCP, for example, a small Node.js or Python service.
- CDK Implementation:
- Use
aws-cdk-lib.aws_ec2 to create private subnets for EC2 instances.
- Use
aws-cdk-lib.aws_autoscaling for the ASG.
- Use
aws-cdk-lib.aws_elasticloadbalancingv2 for the NLB and target groups with TCP listeners.
3. Batch Processing System (Dynamic Scaling)
Use Case: Process data or perform jobs in response to varying levels of demand, such as image processing, file conversion, or machine learning inference tasks.
- Resources:
- VPC with private subnets
- Auto Scaling Group with Spot Instances to reduce costs
- No Load Balancer (instances don’t need to be accessible externally)
- S3 for input/output data storage
- IAM Roles and Policies to access S3
- Launch Template with an AMI configured for your specific task, such as a pre-configured environment for data processing
- Practice Goals:
- Set up ASG to use Spot Instances and scale dynamically based on a custom CloudWatch metric (e.g., jobs in an SQS queue).
- Use a Lifecycle Hook to prepare instances as they scale up and clean up on termination.
- Write a Lambda function to send job completion notifications or trigger next steps.
- CDK Implementation:
- Use
aws-cdk-lib.aws_ec2 for subnets and networking.
- Use
aws-cdk-lib.aws_autoscaling for the ASG with Spot Instances.
- Use
aws-cdk-lib.aws_lambda and aws-cdk-lib.aws_sqs to manage job queues and triggers.
4. High-Availability Web Application with Disaster Recovery Setup
Use Case: Create a fault-tolerant application across multiple regions to practice disaster recovery with automatic scaling.