1. What is Serverless?

Serverless means you don’t manage any servers. AWS handles provisioning, scaling, patching, and availability. You focus only on code and business logic. Pay only for what you use — no idle costs.

Serverless = Not Just Lambda Serverless is an architecture philosophy, not just Lambda. A fully serverless stack: API Gateway (API) + Lambda (compute) + DynamoDB (database) + S3 (storage) + Cognito (auth) + Step Functions (orchestration) + EventBridge (events) + SQS/SNS (messaging) + CloudFront (CDN). Zero servers to manage across the entire application.

2. AWS Serverless Services

3. Serverless Architecture Patterns

Pattern 1: Serverless REST API

Serverless REST API:

  Client → CloudFront → API Gateway (REST/HTTP)
                            |
                     ┌─────┼─────┐
                  Lambda  Lambda  Lambda
                  (GET)   (POST)  (DELETE)
                     |       |       |
                  DynamoDB (single table design)

  Auth: Cognito User Pool + API GW authorizer
  Monitoring: X-Ray + CloudWatch
  Cost: ~$0 at low traffic. Scales to millions of requests.

Pattern 2: Serverless Web Application

Serverless Web App (SPA):

  Static Frontend:
    S3 (host React/Vue/Angular build) → CloudFront (CDN + HTTPS)

  Backend API:
    API Gateway → Lambda → DynamoDB

  Auth:
    Cognito (sign-up, login, JWT tokens, social login)

  File Uploads:
    Client → S3 Pre-signed URL → S3 (direct upload, bypasses Lambda)

  Real-Time:
    API Gateway WebSocket → Lambda → DynamoDB Connections table

Pattern 3: Event Processing Pipeline

Event Processing:

  S3 Upload (new file)
    → EventBridge rule (match ObjectCreated)
      → Step Functions (orchestrate)
        Step 1: Lambda — validate file
        Step 2: Lambda — extract metadata
        Step 3: Lambda — transform data
        Step 4: Lambda — load into DynamoDB
        Step 5: SNS — notify downstream

  On error: DLQ (SQS) + CloudWatch Alarm

Pattern 4: Serverless Data Processing

Serverless Analytics:

  Ingest: Kinesis Firehose (streaming) or S3 (batch uploads)
  Catalog: Glue Crawlers → Glue Data Catalog
  Transform: Glue ETL (serverless Spark)
  Query: Athena (SQL on S3)
  Visualize: QuickSight (serverless BI)
  Govern: Lake Formation (column-level access)

  Entire pipeline: zero servers, zero idle cost.

Pattern 5: Serverless Microservices

Serverless Microservices:

  API Gateway (routes: /orders, /users, /payments)
    |
  /orders  → Lambda → DynamoDB (orders table)
  /users   → Lambda → DynamoDB (users table)
  /payments → Lambda → Stripe API + DynamoDB

  Async communication:
    Order Lambda → EventBridge ("OrderCreated")
      → Rule: trigger Inventory Lambda
      → Rule: trigger Notification Lambda

  Each service: own Lambda + own DynamoDB table + own IAM role

4. Lambda Performance Optimization

Important Warning
Lambda + RDS Anti-Pattern: Each Lambda invocation opens a new DB connection. At high concurrency (1000 Lambdas = 1000 connections), this overwhelms the database. Solution: RDS Proxy pools connections. OR use DynamoDB (connectionless, designed for serverless). This is one of the most tested serverless exam questions.

5. Serverless vs Containers vs EC2

6. When NOT to Use Serverless

  1. Long-running processes (>15 min) — use Fargate or EC2
  2. High-concurrency + relational DB — connection issues (unless RDS Proxy)
  3. Predictable, steady, high traffic — EC2/Fargate with reserved pricing may be cheaper
  4. Need GPU access — Lambda doesn’t support GPU (use EC2 or SageMaker)
  5. Complex networking / VPN requirements — more control with EC2
  6. Very low latency requirements (sub-10ms) — cold starts can add 100ms–3s
Exam Tip Serverless: "Zero servers" = Lambda + API GW + DynamoDB + S3 + Step Functions. "Cold start fix" = Provisioned Concurrency. "Lambda + RDS" = use RDS Proxy (or switch to DynamoDB). "Cheaper Lambda" = Graviton arm64 (20% cheaper). "Java cold start" = SnapStart. "File upload" = S3 pre-signed URL (not through Lambda). "Real-time" = API GW WebSocket. "Long-running" = Fargate (not Lambda). Fully serverless stack = zero idle cost.