Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enterprise AWS ECS Microservice (High-Traffic)

This repository contains the complete AWS Infrastructure-as-Code (CDK in Python) required to deploy and scale a mission-critical, high-traffic async Python microservice (FastAPI/Litestar).

This infrastructure is battle-tested in production, independently handling over 3.5 Million HTTP requests per week.

Production Traffic Proof (Scale)

This single ECS Application Load Balancer is the unified backend for multiple enterprise domains, securely routing and absorbing massive external traffic before it reaches the containerized application.

Traffic from isha.in (3.44 Million Requests / 7 days)

(Please place your Cloudflare screenshot here in the /images folder as cloudflare_ishain.png) Cloudflare Traffic Isha.in

Traffic from sadhguru.org (96k Requests / 7 days)

(Please place your Cloudflare screenshot here in the /images folder as cloudflare_sadhguru.png) Cloudflare Traffic Sadhguru.org

Architecture Overview

The backend application is a modern, async-first FastAPI/Litestar API utilizing MongoDB. Because it relies heavily on non-blocking I/O, the infrastructure was architected to securely scale and manage connection pooling at an enterprise level.

Infrastructure Components (Provisioned via CDK)

  • VPC & Networking: Isolated subnets (Private with Egress) for ECS instances to ensure no direct internet exposure.
  • Application Load Balancer (ALB): Internet-facing ALB acting as the single point of ingress. Cloudflare DNS CNAME records point directly to this ALB.
  • ECS Cluster & EC2 Auto Scaling: Containerized deployment running on ECS-Optimized Amazon Linux 2 instances via an ASG Capacity Provider.
  • Zero-Trust Security: No SSH ports are open. EC2 access is strictly managed via AWS Systems Manager (SSM).
  • Secrets Management: AWS Secrets Manager injects secure credentials directly into the ECS task definition at runtime (aws-msk-config-provider style), completely eliminating hardcoded keys.
  • Observability: CloudWatch Log Groups for centralized container logging and ELK Stack for log aggregation.
  • CI/CD Pipeline: Both the FastAPI application deployments and the CDK infrastructure state are fully automated and managed centrally via GitHub Actions.

Tech Stack

  • Infrastructure as Code (IaC): AWS CDK (Python)
  • CI/CD Pipeline: GitHub Actions
  • Compute Layer: Amazon ECS (Elastic Container Service) on EC2
  • Networking: AWS Application Load Balancer (ALB), Route 53, Cloudflare
  • Application Layer: Python 3.10, Litestar/FastAPI, Pymongo (Async)
  • Database: MongoDB Atlas

Deployment Instructions

Prerequisites

  • Python 3.8+
  • AWS CLI configured
  • AWS CDK CLI installed (npm install -g aws-cdk)

Deployment

# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Synthesize the CloudFormation template
cdk synth

# Deploy to your AWS environment
cdk deploy

About

AWS CDK (Python) infrastructure deploying a high-traffic, async-first Python microservice on ECS serving 3.5M+ weekly requests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages