Marketplace

edge-computing

Use when designing edge computing architectures, serverless at edge, or distributed compute strategies. Covers edge functions, compute placement decisions, Cloudflare Workers, Lambda@Edge, and edge-native patterns.

allowed_tools: Read, Glob, Grep

$ Installieren

git clone https://github.com/melodic-software/claude-code-plugins /tmp/claude-code-plugins && cp -r /tmp/claude-code-plugins/plugins/systems-design/skills/edge-computing ~/.claude/skills/claude-code-plugins

// tip: Run this command in your terminal to install the skill


name: edge-computing description: Use when designing edge computing architectures, serverless at edge, or distributed compute strategies. Covers edge functions, compute placement decisions, Cloudflare Workers, Lambda@Edge, and edge-native patterns. allowed-tools: Read, Glob, Grep

Edge Computing

Comprehensive guide to edge computing architecture - running compute closer to users for lower latency and better performance.

When to Use This Skill

  • Designing edge function architectures
  • Deciding where to place compute (edge vs origin)
  • Implementing serverless at edge
  • Understanding edge platform capabilities
  • Optimizing latency-sensitive applications
  • Building globally distributed applications

Edge Computing Fundamentals

What is Edge Computing?

Compute Placement Spectrum:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                                                             โ”‚
โ”‚  User Device    Edge     Regional    Central    Origin     โ”‚
โ”‚  (Client)       (CDN)    (Cloud)     (Cloud)    (Cloud)    โ”‚
โ”‚                                                             โ”‚
โ”‚     โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ   โ”‚
โ”‚                                                             โ”‚
โ”‚  Lowest         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  Highest   โ”‚
โ”‚  Latency        โ”‚      EDGE COMPUTING         โ”‚  Latency   โ”‚
โ”‚                 โ”‚  (This skill's focus)       โ”‚            โ”‚
โ”‚                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                                                             โ”‚
โ”‚  Limited        โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ  Full      โ”‚
โ”‚  Resources                                       Resources  โ”‚
โ”‚                                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Edge = Running code on CDN/network edge servers (100s of locations)
vs Regional = Running in a few cloud regions (10-20 locations)
vs Origin = Running in one primary location (1-3 locations)

Edge vs Serverless vs Traditional

Comparison:

                    Edge Functions    Cloud Functions    Containers/VMs
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Locations           100-300+          10-20             1-10
Cold Start          <50ms             100ms-seconds     N/A (always warm)
Execution Limit     10-30 seconds     15 minutes        Unlimited
Memory              128MB-1GB         256MB-10GB        Unlimited
CPU                 Limited           Standard          Full control
State               Stateless         Stateless         Stateful OK
Cost Model          Per request       Per request       Per instance
Best For            Low-latency,      General compute   Complex apps,
                    simple logic                        long-running

Use Cases by Type:
Edge: Auth, routing, personalization, A/B tests, redirects
Cloud Functions: APIs, webhooks, background processing
Containers: Full applications, databases, ML inference

Edge Platform Architecture

Edge Platform Components:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Control Plane                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚ Deploy   โ”‚  โ”‚  Config  โ”‚  โ”‚ Secrets  โ”‚  โ”‚ Metrics  โ”‚   โ”‚
โ”‚  โ”‚ API      โ”‚  โ”‚  Store   โ”‚  โ”‚  Mgmt    โ”‚  โ”‚ & Logs   โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚             โ”‚             โ”‚             โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚             โ”‚
        โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
        โ•‘           Global Distribution            โ•‘
        โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
                      โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                 โ”‚                 โ”‚
โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”
โ”‚ Edge  โ”‚        โ”‚ Edge  โ”‚        โ”‚ Edge  โ”‚
โ”‚ POP 1 โ”‚        โ”‚ POP 2 โ”‚        โ”‚ POP N โ”‚
โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”โ”‚        โ”‚โ”Œโ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚โ”‚ V8  โ”‚โ”‚        โ”‚โ”‚ V8  โ”‚โ”‚        โ”‚โ”‚ V8  โ”‚โ”‚
โ”‚โ”‚Isol.โ”‚โ”‚        โ”‚โ”‚Isol.โ”‚โ”‚        โ”‚โ”‚Isol.โ”‚โ”‚
โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚        โ”‚โ””โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Execution Model:
- V8 Isolates: Lightweight isolation (not containers)
- Instant cold start (sub-50ms)
- Per-request execution
- Auto-scaled per POP

Edge Function Patterns

Request Interception

Request/Response Lifecycle:

User Request โ”€โ”€โ–บ Edge Function โ”€โ”€โ–บ Origin (optional)
                      โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚               โ”‚
         Modify Request   Short-circuit
         (continue to    (return response
          origin)         from edge)

Use Cases:

1. URL Rewriting
   /old-page โ†’ /new-page
   /api/v1/* โ†’ /api/v2/*

2. Header Manipulation
   Add security headers
   Add request ID
   Normalize Accept-Language

3. Authentication
   Validate JWT at edge
   Check API key
   Redirect to login

4. A/B Testing
   Assign cohort
   Rewrite to variant URL

5. Bot Protection
   Challenge bots
   Block known bad actors

6. Geolocation Routing
   Route to regional origin
   Apply regional rules

Response Transformation

Response Transformation Patterns:

1. HTML Injection
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Inject analytics, A/B test scripts     โ”‚
   โ”‚ Add personalized content               โ”‚
   โ”‚ Insert GDPR banners by region          โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2. Content Optimization
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Compress responses                      โ”‚
   โ”‚ Image optimization/resizing            โ”‚
   โ”‚ Minification                           โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3. Response Caching
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Cache API responses at edge            โ”‚
   โ”‚ Assemble from cache fragments          โ”‚
   โ”‚ Serve stale while revalidating         โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4. Error Handling
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Fallback pages on origin error         โ”‚
   โ”‚ Custom error pages per region          โ”‚
   โ”‚ Retry logic with backoff               โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Edge Storage Patterns

Edge Storage Options:

1. Key-Value Store (KV)
   โ”œโ”€โ”€ Read-heavy workloads
   โ”œโ”€โ”€ Eventually consistent
   โ”œโ”€โ”€ Low latency reads
   โ””โ”€โ”€ Limited write throughput

   Use: Feature flags, configuration, user sessions

2. Durable Objects (Cloudflare)
   โ”œโ”€โ”€ Strong consistency
   โ”œโ”€โ”€ Stateful edge compute
   โ”œโ”€โ”€ Single-instance per ID
   โ””โ”€โ”€ WebSocket support

   Use: Real-time collaboration, chat, gaming state

3. Edge Databases
   โ”œโ”€โ”€ Distributed SQL (PlanetScale, Turso)
   โ”œโ”€โ”€ Read replicas at edge
   โ”œโ”€โ”€ Low latency reads
   โ””โ”€โ”€ Write to primary region

   Use: User data, product catalogs, CMS

4. R2/S3-Compatible Storage
   โ”œโ”€โ”€ Object storage at edge
   โ”œโ”€โ”€ No egress fees (some providers)
   โ””โ”€โ”€ Large file storage

   Use: Static assets, user uploads, backups

Compute Placement Decisions

Decision Framework

Where Should This Run?

Question 1: Latency Requirements
โ”œโ”€โ”€ <50ms required? โ†’ Edge
โ”œโ”€โ”€ <200ms acceptable? โ†’ Regional cloud
โ””โ”€โ”€ Latency not critical? โ†’ Central origin

Question 2: Compute Complexity
โ”œโ”€โ”€ Simple transformations? โ†’ Edge
โ”œโ”€โ”€ Moderate logic? โ†’ Edge or Regional
โ””โ”€โ”€ Complex processing? โ†’ Regional or Central

Question 3: Data Dependencies
โ”œโ”€โ”€ No data needed? โ†’ Edge
โ”œโ”€โ”€ Read-heavy, cacheable? โ†’ Edge with cache
โ”œโ”€โ”€ Strong consistency needed? โ†’ Regional
โ””โ”€โ”€ Write-heavy? โ†’ Central

Question 4: State Requirements
โ”œโ”€โ”€ Stateless? โ†’ Edge
โ”œโ”€โ”€ Session state? โ†’ Edge with KV/Durable Objects
โ””โ”€โ”€ Complex state? โ†’ Regional or Central

Question 5: Cost Sensitivity
โ”œโ”€โ”€ High request volume, simple? โ†’ Edge (efficient)
โ”œโ”€โ”€ CPU-intensive? โ†’ Regional (cheaper)
โ””โ”€โ”€ Long-running? โ†’ Central

Hybrid Architecture

Hybrid Edge + Origin Architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Edge Layer                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  โ€ข Authentication/Authorization                     โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Rate limiting                                    โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Request routing                                  โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Static content                                   โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Simple personalization                           โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Caching logic                                    โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                  Only complex requests pass through
                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       Origin Layer                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  โ€ข Business logic                                   โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Database operations                              โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Third-party integrations                         โ”‚    โ”‚
โ”‚  โ”‚  โ€ข ML inference                                     โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Complex computations                             โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Benefits:
- Offload work from origin
- Faster responses for simple requests
- Origin protected from attack traffic
- Scale each layer independently

Edge Platforms

Cloudflare Workers

Cloudflare Workers:

Execution:
- V8 isolates (not containers)
- <5ms cold start
- 200+ edge locations
- 10ms CPU time (free) / 30s (paid)

Features:
โ”œโ”€โ”€ Workers KV (key-value store)
โ”œโ”€โ”€ Durable Objects (stateful)
โ”œโ”€โ”€ R2 (object storage)
โ”œโ”€โ”€ D1 (SQLite at edge)
โ”œโ”€โ”€ Queues (async processing)
โ””โ”€โ”€ Hyperdrive (database connection pooling)

Example:
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);

    // Simple routing
    if (url.pathname.startsWith('/api/')) {
      return handleAPI(request, env);
    }

    // Serve static
    return env.ASSETS.fetch(request);
  }
}

AWS Lambda@Edge / CloudFront Functions

AWS Edge Options:

CloudFront Functions:
โ”œโ”€โ”€ JavaScript only
โ”œโ”€โ”€ Sub-millisecond start
โ”œโ”€โ”€ 2MB memory
โ”œโ”€โ”€ Request/response manipulation only
โ”œโ”€โ”€ Cannot make network calls
โ””โ”€โ”€ Very cheap at scale

Lambda@Edge:
โ”œโ”€โ”€ Node.js, Python
โ”œโ”€โ”€ 128-3008MB memory
โ”œโ”€โ”€ Up to 30s execution (origin response)
โ”œโ”€โ”€ Can make network calls
โ”œโ”€โ”€ Access to AWS services
โ””โ”€โ”€ Higher latency than CF Functions

Use Case Mapping:
CloudFront Functions: Headers, redirects, URL rewrites
Lambda@Edge: Auth, A/B testing, dynamic responses
Lambda (Regional): Full API logic, database access

Fastly Compute@Edge

Fastly Compute@Edge:

Execution:
- WebAssembly-based (Wasm)
- Multi-language (Rust, JS, Go, etc.)
- No cold start (pre-compiled)
- 50ms-120s execution time

Features:
โ”œโ”€โ”€ Geolocation data
โ”œโ”€โ”€ Device detection
โ”œโ”€โ”€ Real-time logging
โ”œโ”€โ”€ Edge dictionaries
โ””โ”€โ”€ Origin fetch with caching

Strengths:
- Best for dynamic content
- Real-time purging
- Advanced caching control
- Strong VCL migration path

Example (Rust):
use fastly::{Request, Response};

#[fastly::main]
fn main(req: Request) -> Result<Response, Error> {
    match req.get_path() {
        "/api" => handle_api(req),
        _ => Ok(req.send("origin")?)
    }
}

Best Practices

Edge Computing Best Practices:

1. Keep It Simple
   โ–ก Edge = simple, fast operations
   โ–ก Complex logic โ†’ origin
   โ–ก Minimize dependencies
   โ–ก Fail fast and gracefully

2. Optimize Cold Start
   โ–ก Minimize code size
   โ–ก Lazy load where possible
   โ–ก Use global scope for init
   โ–ก Avoid heavy dependencies

3. Handle Failures
   โ–ก Origin unavailable handling
   โ–ก Timeout handling
   โ–ก Fallback responses
   โ–ก Error tracking

4. Monitor Everything
   โ–ก Latency percentiles
   โ–ก Error rates
   โ–ก Cold start frequency
   โ–ก Origin fallthrough rate

5. Security
   โ–ก Validate input at edge
   โ–ก Rate limit early
   โ–ก Sanitize data
   โ–ก Use secrets management

6. Cost Optimization
   โ–ก Cache aggressively
   โ–ก Right-size execution time
   โ–ก Use appropriate tier
   โ–ก Monitor usage patterns

Anti-Patterns

Edge Computing Anti-Patterns:

1. "Everything at Edge"
   โŒ Moving all logic to edge
   โœ“ Strategic placement based on requirements

2. "Database at Edge"
   โŒ Complex database operations at edge
   โœ“ Read replicas or cached data at edge

3. "Ignoring Cold Starts"
   โŒ Large bundles, heavy initialization
   โœ“ Optimize bundle size, lazy loading

4. "Origin Coupling"
   โŒ Edge functions tightly coupled to origin
   โœ“ Edge functions should work independently when possible

5. "No Fallbacks"
   โŒ Edge function fails = user sees error
   โœ“ Graceful degradation, cached responses

6. "Synchronous Everything"
   โŒ Waiting for slow operations at edge
   โœ“ Async processing, fire-and-forget logging

Related Skills

  • cdn-architecture - CDN and caching patterns
  • serverless-patterns - Serverless architecture
  • latency-optimization - End-to-end latency reduction
  • multi-region-deployment - Global infrastructure