AWS Architecture & Services Deep Dive

AWS Compute Services: EC2, Lambda, ECS & EKS

4 min read

Compute service selection is one of the most common interview topics. Understanding when to use each service demonstrates architectural maturity.

EC2: The Foundation

Instance Types & Selection

FamilyUse CaseExample
General Purpose (M/T)Web servers, small DBsm7i.xlarge, t3.medium
Compute Optimized (C)Batch processing, gamingc7i.2xlarge
Memory Optimized (R/X)In-memory databasesr7i.4xlarge, x2idn.large
Storage Optimized (I/D)Data warehousing, HDFSi4i.large, d3.xlarge
Accelerated (P/G)ML training, graphicsp5.48xlarge, g5.xlarge

Interview Question: Right-sizing

Q: "Your web application uses m5.2xlarge instances but CPU averages 15%. What do you recommend?"

A: Analyze CloudWatch metrics for CPU, memory, and network. Consider:

  1. Downsize to m5.large (4x smaller, 4x cheaper)
  2. Use Compute Savings Plans for predictable workloads (up to 72% savings)
  3. Consider Graviton-based instances (m7g/Graviton3 or m8g/Graviton4) for additional 20-40% cost reduction
  4. Implement auto-scaling to handle peaks

Lambda: Serverless Compute

Key Characteristics

  • Max duration: 15 minutes
  • Memory: 128 MB to 10,240 MB
  • Concurrency: 1,000 default (can increase)
  • Cold start: 100ms-1s (varies by runtime)

When to Use Lambda

Good Fit:

  • Event-driven processing (S3 triggers, API Gateway)
  • Short-running tasks (< 15 min)
  • Variable/unpredictable traffic
  • Microservice APIs with low latency requirements

Poor Fit:

  • Long-running processes (use Step Functions or ECS)
  • High-frequency, consistent load (EC2 cheaper at scale)
  • GPU-intensive workloads

Interview Question: Lambda vs EC2 Cost

Q: "Your API receives 10M requests/month, each taking 200ms and using 512MB. Should you use Lambda or EC2?"

A: Calculate Lambda cost:

  • Requests: 10M × $0.20/1M = $2.00
  • Compute: 10M × 0.2s × 0.5GB × $0.0000166667 = $16.67
  • Total: ~$19/month

EC2 t3.medium could handle this but requires management overhead. Lambda wins for simplicity at this scale. Beyond ~50M requests/month, EC2 becomes more cost-effective.

ECS: Container Orchestration

Launch Types

TypeUse CasePricing
EC2Control over infrastructurePay for EC2 instances
FargateServerless containersPay per vCPU/memory-hour

⚠ Prices change frequently. The values above are for illustration only and may be out of date. Always verify current pricing directly with the provider before making cost decisions: Anthropic · OpenAI · Google Gemini · Google Vertex AI · AWS Bedrock · Azure OpenAI · Mistral · Cohere · Together AI · DeepSeek · Groq · Fireworks AI · Perplexity · xAI · Cursor · GitHub Copilot · Windsurf.

ECS Architecture Components

  • Cluster: Logical grouping of services
  • Service: Maintains desired task count
  • Task Definition: Container configuration (like Dockerfile + docker-compose)
  • Task: Running container instance

Interview Question: ECS vs EKS

Q: "When would you choose ECS over EKS?"

A: Choose ECS when:

  • AWS-native integration is priority
  • Team lacks Kubernetes expertise
  • Simpler deployment model is acceptable
  • Vendor lock-in is not a concern

Choose EKS when:

  • Kubernetes expertise exists on team
  • Multi-cloud portability needed
  • Rich Kubernetes ecosystem required
  • Complex networking (service mesh) needed

EKS: Managed Kubernetes

EKS Pricing

  • Control plane: $0.10/hour (~$73/month)
  • Worker nodes: EC2/Fargate pricing
  • No additional charge for managed add-ons

Interview Question: EKS Node Types

Q: "What are the trade-offs between managed node groups, self-managed nodes, and Fargate for EKS?"

OptionProsCons
Managed Node GroupsAWS handles updates, easy scalingLess customization
Self-Managed NodesFull control, custom AMIsYou manage updates
FargateServerless, no nodes to manageHigher cost per vCPU, limited features

Compute Decision Framework

Need GPU? → P/G instance types
Need serverless?
  └── Short-lived (< 15min)? → Lambda
  └── Longer? → Fargate or Step Functions
Need containers?
  └── Kubernetes required? → EKS
  └── Simpler model? → ECS
Default → EC2 with Auto Scaling

Interview Tip: Always discuss cost implications, scaling behavior, and operational overhead when comparing compute options.

Next, we'll explore AWS storage services and selection criteria. :::

Quick check: how does this lesson land for you?

Quiz

Module 2: AWS Architecture & Services Deep Dive

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.