DuoKart. Prathamesh Lonare · DevOps

Resilient Multi-Tier Cloud Architecture

A small-shop order engine engineered on AWS across two Availability Zones. Decoupled via asynchronous queues and automated self-healing to prevent lost orders and isolate database failures during festival traffic rushes.

System Overview

What Was Built

A multi-tier retail order and billing backend on AWS. An internet-facing Application Load Balancer routes traffic to private EC2 instances (Auto Scaling Group) across two Availability Zones. Backed by private Multi-AZ RDS MySQL, direct S3 uploads, and SQS/Lambda asynchronous order decoupling.

Primary Goal Zero Lost Orders
High Availability 2 Availability Zones
50/50 Collaboration

My Personal Contribution (Prathamesh)

Collaborative build with Swapnil Kumbhare. 60+ alternating Git commits verify joint authorship.

  • Compute & App Layer: Built Flask REST API, systemd bootstrap unit, and EC2 Auto Scaling launch configuration.
  • Database Integration: Connected private RDS MySQL with dynamic SSM Parameter Store secret injection.
  • Direct File Storage: Implemented presigned S3 PUT endpoints to keep heavy file uploads off the application servers.
  • Asynchronous Logic: Built order idempotency via orderId to prevent duplicate charges and state regression.
  • Chaos Testing: Executed live EC2 termination drill, proving continuous 200 OK client availability.

Partner Contribution (Swapnil): VPC networking, CloudFormation base templates, and CloudWatch alarms/dashboard.

Economics & Governance

Cost Discipline

Architected on an AWS Free Tier account with strict spending guardrails. Total spend to build the entire system was approximately $20 to $25.

Daily Active Burn ~$3.01 / day (RDS Multi-AZ + ALB + NAT)
Budget Ceiling $20.00 / month (Automated alert at 60% and 100%)
Decommissioning Deleted 2026-09-26 per destroy checklist
AWS services and stack:
AWS VPC (2 AZs) Application Load Balancer EC2 Auto Scaling RDS MySQL Multi-AZ Amazon S3 Presigned SQS Standard + DLQ AWS Lambda (Py 3.12) DynamoDB Amazon SNS CloudWatch (8 Alarms) AWS Budgets CloudFormation Python / Flask Ubuntu Linux

Verified AWS Console Receipts

Real console evidence captured during testing before infrastructure teardown. Click any plate to inspect full screenshots.

EC2 instance termination in AWS console Click to Enlarge

1. EC2 Self-Healing Drill

Manually terminated instance i-0c7ae07e in us-east-2a. ASG replaced it in 4 min while ALB maintained uninterrupted 200 OK traffic.

View Termination Proof →
CloudWatch dashboard for duokart-dev Click to Enlarge

2. Telemetry Control Room

Live dashboard: ALB requests, host health (2 healthy targets), RDS CPU, free storage trend, SQS message age, and DLQ poison depth.

View Telemetry Proof →
AWS Budgets console showing $20 limit Click to Enlarge

3. AWS Budget Governance

Cost discipline on a $25 student budget: $20 cap with email alerts at 60% ($12) and 100% forecast. Actual spend: ~$20 to $25.

View Billing Proof →
PowerShell curl and Gmail notification Click to Enlarge

4. Async Order Pipeline

PowerShell API call returned 202 RECEIVED; Lambda flipped status to PACKING; verified SNS confirmation email delivered to Gmail.

View Pipeline Proof →

End-to-End System Architecture

Requests enter via an internet-facing Application Load Balancer and terminate at private compute nodes. Relational persistence, file storage, and asynchronous processing are segregated into distinct security groups and fault domains.

AWS Architecture Map: us-east-2 (Ohio)
DuoKart AWS Architecture Schematic: Public ALB, Multi-AZ ASG, Multi-AZ RDS, SQS, Lambda, DynamoDB, CloudWatch
Production schematic: Web traffic passes from ALB (port 80) to private EC2 ASG (port 5000); relational persistence is restricted to RDS MySQL (port 3306); orders decouple into SQS Standard with Dead-Letter Queue redrive.
Tier 1: Ingress

Public Load Balancing

Internet-facing ALB spans Public Subnet 1 (2a) and Public Subnet 2 (2b). Absorbs traffic surges and health-checks backend instances on port 5000 via /health.

Port 80 Inbound → Port 5000 Backend
Tier 2: Compute

Private Auto Scaling Group

EC2 instances run in private subnets with zero public IPs. Inbound traffic allowed strictly from ALB security group. Outbound internet egress routed through a single NAT Gateway.

Min: 2, Max: 4 (t3.micro, Ubuntu 24.04)
Tier 3: Persistence

Multi-AZ RDS MySQL 8.0

Stores catalog and relational orders. Automatic synchronous standby in AZ-2b. Port 3306 locked down exclusively to compute security group; public accessibility disabled.

Synchronous Standby Failover
Tier 4: Asynchronous

SQS Queue & Lambda Worker

Orders decouple into SQS Standard returning immediate HTTP 202. Dead-Letter Queue catches poison orders after 3 retries. Lambda worker performs conditional DynamoDB writes.

DLQ Redrive (maxReceiveCount: 3)

Subsystem Isolation Specifications

Configuration parameters, security group bindings, and failure protections declared in CloudFormation.

Eight Alarms, One Mailbox

Configured in CloudWatch to alert via SNS before buyers notice latency or failures. Three alarms indicate “Insufficient Data” during normal steady-state operations, signifying zero errors rather than broken instrumentation.

Alarm Metric Trigger Criteria Operational Rationale Healthy State
alb-5xx 5xx > 10 / 5 min Flask 500 errors occur only on unhandled server exceptions or application crashes. Active (OK)
alb-unhealthy unhealthy > 0 for 2 min Provides an early warning buffer before Auto Scaling instance replacement completes. Active (OK)
rds-cpu CPU > 80% × 3 db.t3.micro is a burstable instance; sustained 80% utilization signals a query bottleneck or memory leak. Active (OK)
rds-storage free < 5 GB Early warning on 20 GB gp2 allocation, triggering storage auto-scale before disk exhaustion. Active (OK)
sqs-age oldest > 300 s Catches worker lag if an order sits unserved in the ingestion queue for over 5 minutes. Active (OK)
dlq-depth visible ≥ 1 Any poison or unparseable payload moved to Dead-Letter Queue immediately pages on-call. 0 (Insufficient)
worker-errors errors > 0 Lambda worker execution failure: bad schema, SNS publish deny, or DynamoDB write rejection. 0 (Insufficient)
ddb-throttle throttles > 0 Signals a hot orderId partition write spike exceeding provisioned capacity. 0 (Insufficient)

Try the Order Flow

The AWS backend was decommissioned on 2026-09-26 to control costs ($20 budget cap). This interactive console simulates the exact API contract, idempotency validation, status transitions, and notification dispatch directly in your browser.

duokart-order-simulation :5000
$ POST /orders (Demo: Neem Soap × 3 @ ₹99 = ₹297)
202 {"orderId": "ord-000050", "status": "RECEIVED"}
  • [DONE] RECEIVED
  • [DONE] PACKING
  • [WAIT] DELIVERED

SNS Owner Alert: New order ord-000050 RECEIVED (3 items @ 99)

SNS Buyer Alert: Order ord-000050 is PACKING. Total: 297



          
Equivalent curl command: curl -X POST $ALB_DNS/orders -H "Content-Type: application/json" -d '{"orderId":"ord-000050","items":[{"sku":"soap-neem-100g","qty":3,"price":99}],"total":297}'