Beginner SaaS & Marketing Tech Serverless Low Latency

Global Serverless URL Shortener: Sub-15ms Redirection

Architecting a high-throughput, low-latency URL redirection engine with API Gateway HTTP APIs, Lambda, and DynamoDB single-table design.

Estimated Reading Time: 6 mins
AWS Services: 3 integrated
Production Benchmark & ROI Targets
p99 Redirect Latency
14ms
Cost per 1M Redirects
$1.42
Availability SLA
99.99%

1. Business Problem & Context

A digital marketing enterprise needed a branded URL shortener service handling over 30 million link clicks monthly. Traditional relational database architectures struggled with read concurrency and incurred high baseline server hosting fees even during off-peak hours.

2. Requirements & Constraints

  • Sub-20ms Redirects: Return HTTP 301 Moved Permanently immediately.
  • Near-Zero Maintenance: Completely serverless infrastructure with auto-scaling.
  • Cost Optimization: Budget under $50/month for 30 million monthly link visits.

3. Architecture Overview & Data Flow

Serverless URL Shortener Architecture
Rendering Architecture Topology...

Interactive Architecture Diagram (Use controls to zoom & pan)

4. AWS Services Used & Rationales

AWS Services Architecture Rationale

Concrete reasons why these specific services were chosen over alternatives

Service Category Architectural Rationale ("Why this service?")
API Gateway HTTP APIs Serverless Chosen over REST APIs for 60% lower latency overhead and $1.00/million pricing.
AWS Lambda (Graviton2 ARM64) Compute Delivers 20% better price-performance compared to x86_64 architectures.
Amazon DynamoDB (On-Demand) Database Provides consistent 2-4ms key-value lookups with zero capacity provisioning required.

5. Key Design Trade-offs

Architecture Decision & Trade-Off Matrix

Evaluating alternative approaches under real-world constraints

API Gateway REST APIs

  • + Built-in API keys
  • + Request validation models
  • $3.50/million requests
  • Higher latency (30-50ms)
Architectural Verdict: Unnecessary cost and latency for simple redirects.

API Gateway HTTP APIs + DynamoDB (Chosen)

✓ Chosen Design
  • + $1.00/million requests
  • + Sub-15ms response times
  • + Zero cold start latency on small bundles
  • Fewer legacy transformation features
Architectural Verdict: Perfect fit for high-volume, low-complexity routing.

6. Implementation Highlights

Code Recipe Sub-5ms Lambda 301 Redirect Handler
import { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb";
const ddb = new DynamoDBClient({ region: process.env.AWS_REGION });

export const handler = async (event) => {
  const code = event.pathParameters.code;
  const result = await ddb.send(new GetItemCommand({
    TableName: process.env.TABLE_NAME,
    Key: { PK: { S: `SHORT#${code}` } }
  }));

  if (!result.Item) {
    return { statusCode: 404, body: "Short link not found" };
  }

  return {
    statusCode: 301,
    headers: { Location: result.Item.targetUrl.S, "Cache-Control": "public, max-age=86400" }
  };
};

7. Results & Key Metrics

  • Median Latency: 11ms globally.
  • Monthly Hosting Cost: $42.60 for 30,000,000 requests.

8. Key Architectural Takeaways

Cost Tip: For microservices that only route or proxy requests, always default to API Gateway HTTP APIs rather than REST APIs to save 70% on networking costs.

9. Interactive Knowledge Check

Architecture Knowledge Check
Question1of1
Question01

Why does adding a Cache-Control: max-age=86400 header to 301 redirects optimize architecture performance?

10. Official AWS References