Contents:
Overview
The Application Load Balancer (ALB) will distribute incoming traffic to multiple services (microservices) running on ECS Fargate.
ALB supports path-based routing and host-based routing, allowing requests to be directed to the correct service.
Benefits:
- Load balances traffic across multiple service instances
- Ensures high availability and fault tolerance
- Easily scales to handle increased traffic
Create an Application Load Balancer (ALB)
- Go to EC2 Console → Load Balancers → Create Load Balancer
- Select Application Load Balancer
- Name:
fargate-alb
- Scheme: Internet-facing (for public access)
- IP address type: IPv4
- Select your VPC and at least 2 subnets in different Availability Zones (Multi-AZ)
- Security Group:
- Allow HTTP (80) and HTTPS (443) if using SSL
- Skip Target Group creation for now (will create later)
- Click Create Load Balancer
Create Target Groups
- Go to EC2 Console → Target Groups → Create target group
- Target type: IP addresses
- Name:
api-target-group
- Protocol: HTTP, Port: 8080 (or your API service port)
- Select your VPC
- Health check path:
/health
- Create an additional target group for the Frontend:
- Name:
frontend-target-group
- Port: 80
- Health check path:
/
Attach Services to Target Groups
- Go to ECS Console → Cluster → Service → Select the service you want to configure
- Edit the service → In the Load balancing section:
- Select Application Load Balancer
- Listener: HTTP 80 (or HTTPS 443 if SSL is enabled)
- Choose the corresponding Target Group (API →
api-target-group
, Frontend → frontend-target-group
)
- Save and redeploy the service
Test the Setup
- Go to EC2 Console → Load Balancers → Select
fargate-alb
- Copy the ALB DNS name
- Access it in your browser:
http://<ALB_DNS>/
→ should display the frontendhttp://<ALB_DNS>/api/health
→ should return the API health check response
- Ensure that the Target Group status shows healthy