Cloud Infrastructure Design

Explore system architectures at three scales—from hobby projects to global scale. Click components to learn about services, costs, and trade-offs.

Infrastructure as Code • Multi-Region • Auto-Scaling
Architecture Diagram — Hobby / MVP
Cloud Provider Region 👤 User ☁️ CDN Cloudflare Pages Serverless API Cloudflare Workers 🗄️ Managed DB Supabase / D1
👤

Component Name

COMPONENT TYPE
What It Does
Description here
Cloud Services
Service A, Service B
Est. Monthly Cost
$0-10
Why At This Scale
Reason here
Infrastructure as Code — Terraform (Hobby)
# Cloudflare Workers + D1 Database # Perfect for hobby projects with minimal cost terraform { required_providers { cloudflare = { source = "cloudflare/cloudflare" version = "~> 4.0" } } } provider "cloudflare" { api_token = var.cloudflare_api_token account_id = var.cloudflare_account_id } # D1 Database (Serverless SQLite) resource "cloudflare_d1_database" "app_db" { account_id = var.cloudflare_account_id name = "observatory-hobby-db" } # Worker Script resource "cloudflare_worker_script" "api" { name = "observatory-api" content = file("./worker.js") d1_database { binding = "DB" database_id = cloudflare_d1_database.app_db.id } } # Custom Domain Routing resource "cloudflare_worker_route" "api_route" { pattern = "api.example.com/*" worker_name = cloudflare_worker_script.api.name zone_id = var.zone_id }

Click to Learn More

Line 24-28
D1 Database Binding — Connects the Worker to a serverless SQLite database. No connection pooling needed.
Line 31-40
Worker Script — Edge-computed API running globally. Cold starts under 50ms.
Line 43-48
Route Pattern — Maps custom domain paths to the Worker. Handles SSL automatically.
Architecture Diagram — Startup
VPC / Private Subnet 👤 User ☁️ CDN CloudFront ⚖️ Load Balancer ALB / NLB Auto-Scaling Group 🖥️ App 🖥️ App 🔴 Redis Cache 🗄️ Primary DB RDS PostgreSQL 🗄️ Read Replica Async Copy 📦 Object Store
👤

Component Name

COMPONENT TYPE
What It Does
Description here
Cloud Services
Service A, Service B
Est. Monthly Cost
$0-10
Why At This Scale
Reason here
Infrastructure as Code — Terraform (Startup)
# AWS ALB + Auto-Scaling Group + RDS # Production-ready for growing startups terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 5.0" } } } # Application Load Balancer resource "aws_lb" "app_alb" { name = "observatory-alb" internal = false load_balancer_type = "application" security_groups = [aws_security_group.alb.id] subnets = var.public_subnet_ids } # Auto-Scaling Group resource "aws_autoscaling_group" "app_asg" { name = "observatory-asg" min_size = 2 max_size = 10 desired_capacity = 2 health_check_type = "ELB" launch_template { id = aws_launch_template.app.id version = "$Latest" } } # RDS PostgreSQL Instance resource "aws_db_instance" "primary" { identifier = "observatory-db" engine = "postgres" engine_version = "15.4" instance_class = "db.t3.medium" allocated_storage = 100 multi_az = true storage_encrypted = true }

Click to Learn More

Line 13-20
Application Load Balancer — Distributes traffic across app servers. Handles SSL termination and health checks.
Line 23-35
Auto-Scaling Group — Maintains 2-10 instances based on CPU/memory metrics. Zero-downtime deployments.
Line 38-48
RDS with Multi-AZ — Automatic failover to standby. Encrypted storage for compliance.
Architecture Diagram — Scale
🌐 Global CDN CloudFront + Lambda@Edge Region: us-east-1 Region: eu-west-1 ⚖️ Regional LB NLB Kubernetes Cluster 📦 Pod 📦 Pod 📦 Pod 📦 Pod 🔴 Redis Cluster 📨 Message Queue 🗄️ Primary DB Aurora Global 🗄️ Read Replicas Multi-Region ⚙️ Background Workers 📊 Monitoring
👤

Component Name

COMPONENT TYPE
What It Does
Description here
Cloud Services
Service A, Service B
Est. Monthly Cost
$0-10
Why At This Scale
Reason here
Infrastructure as Code — Terraform (Scale)
# Kubernetes Deployment + Service + Ingress # Global scale with multi-region support terraform { required_providers { kubernetes = { source = "hashicorp/kubernetes" version = "~> 2.23" } aws = { source = "hashicorp/aws" version = "~> 5.0" } } } # EKS Cluster resource "aws_eks_cluster" "main" { name = "observatory-cluster" role_arn = aws_iam_role.cluster.arn version = "1.28" vpc_config { subnet_ids = var.private_subnet_ids endpoint_private_access = true endpoint_public_access = true } } # Kubernetes Deployment resource "kubernetes_deployment" "app" { metadata { name = "observatory-app" } spec { replicas = 6 selector { match_labels = { app = "observatory" } } template { metadata { labels = { app = "observatory" } } spec { container { name = "app" image = "observatory/app:latest" resources { limits = { cpu = "1000m" memory = "1Gi" } } } } } } } # Ingress with AWS ALB Controller resource "kubernetes_ingress" "app" { metadata { name = "observatory-ingress" annotations = { "kubernetes.io/ingress.class" = "alb" "alb.ingress.kubernetes.io/scheme" = "internet-facing" } } }

Click to Learn More

Line 17-30
EKS Cluster — Managed Kubernetes control plane. Private + public endpoints for security.
Line 33-60
K8s Deployment — 6 replicas with resource limits. Rolling updates with zero downtime.
Line 63-73
Ingress + ALB — AWS ALB Controller provisions load balancer automatically. SSL via ACM.
Cost Comparison Across Scales
Hobby / MVP
$0-20/mo
Startup
$200-800/mo
Scale
$2K-10K/mo

Primary Cost Drivers

Hobby / MVP
  • Free tier CDN (Cloudflare)
  • Serverless compute (pay-per-request)
  • Managed DB free tier (Supabase/D1)
  • Single region, no redundancy
Startup
  • ALB + 2-10 EC2 instances
  • RDS with Multi-AZ failover
  • ElastiCache Redis cluster
  • S3 storage + data transfer
Scale
  • EKS cluster + node groups
  • Aurora Global Database
  • Multi-region deployment
  • Redis Cluster + MQ + Workers
  • Monitoring & observability stack

What This Proves

Architecture Scaling

Knowing when to add complexity is crucial. Start simple with serverless + managed DB, then evolve to auto-scaling + caching, and finally K8s + multi-region only when needed.

Infrastructure as Code

Terraform enables reproducible, version-controlled infrastructure. The same patterns scale from cloudflare_worker_script to kubernetes_deployment with consistent tooling.

Cloud Service Selection

Managed services reduce ops overhead but increase cost. Trade-offs: Supabase vs RDS vs Aurora Global—each fits different scale requirements.

Cost Awareness

Right-sizing infrastructure prevents waste. A hobby project doesn't need Multi-AZ RDS, and a scale system can't run on free-tier Lambda alone.

Network Design

VPCs, subnets, and security groups form the foundation. Public subnets for load balancers, private subnets for app servers + databases, with strict security group rules.

High Availability Patterns

Multi-AZ databases, read replicas, auto-scaling groups, and multi-region deployments ensure uptime. 99.9%99.99%99.999% availability targets.