A production-grade, event-driven serverless architecture built with AWS CDK (Python). This project was designed to solve critical database bottleneck issues during massive, spiky traffic events (such as the Mahashivratri live stream).
During large-scale global streaming events, the system experiences sudden, massive spikes in donation and registration traffic. Traditional monolithic REST APIs coupled directly to relational databases (RDS) often suffer from connection exhaustion, row-locking, and ultimately crash under the load, resulting in dropped requests.
This architecture completely decouples the ingestion layer from the database processing layer using Amazon EventBridge.
- Ingestion: An API Gateway triggers a fast-executing Ingestion Lambda. This Lambda simply validates the payload, publishes a
DonationReceivedevent to a custom EventBus, and immediately returns a200 OKto the user. - Routing: Amazon EventBridge routes the event asynchronously.
- Processing: A secondary Processor Lambda picks up the event and performs the heavy lifting (writing to the database, triggering emails, etc.).
- Storage: DynamoDB (configured with On-Demand
PAY_PER_REQUESTbilling) easily absorbs the sudden write capacity spikes without throttling.
[ User / Frontend ]
│
▼ (HTTP POST)
[ Amazon API Gateway ]
│
▼
[ Ingestion Lambda ] ──► (Returns 200 OK Fast!)
│
▼ (Publishes Event)
[ Amazon EventBridge (Custom Bus) ]
│
▼ (Asynchronous Trigger)
[ Processor Lambda ]
│
▼
[ Amazon DynamoDB ]
- Infrastructure as Code (IaC): AWS CDK (Python)
- Compute: AWS Lambda
- API Routing: Amazon API Gateway
- Event Bus: Amazon EventBridge
- Database: Amazon DynamoDB
/lambda_functions/ingestion.py: The fast-response API handler./lambda_functions/processor.py: The asynchronous database writer./mahashivratri_donation_processor/: The AWS CDK Stack defining all IAM permissions, EventBridge rules, and infrastructure.
This project is built using the AWS Cloud Development Kit (CDK).
# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install requirements
pip install -r requirements.txt
# Synthesize the CloudFormation template
cdk synth
# Deploy to your AWS Account
cdk deploy