Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Edge Computing
HLD

Edge Computing

Running your code at CDN locations — the model, what belongs there, and the constraints that shape it.

From Cache to Compute

 classic edge: serves cached copies; misses travel to origin.
 edge compute: YOUR CODE executes AT the edge location.

 user ──15ms──► [edge: runs your function]
                    │ can now:
                    │ - transform requests/responses
                    │ - auth/route/personalize LOCALLY
                    │ - call origin only when truly needed

 the shift: from "cache decisions made centrally" to
 "logic distributed globally."

What Edge Compute Actually Is

 deployment model: upload code once → replicated to ~300 POPs
 execution model: serverless-style — no servers to manage,
                  scale is automatic (per-request isolation)
 latency model:   compute happens ~10-30ms from users
                  instead of ~100-300ms at a central region

 platforms: Cloudflare Workers, Fastly Compute@Edge,
            AWS Lambda@Edge/CloudFront Functions, Akamai EdgeWorkers
 
 all share a shape: V8-isolate-class runtimes, sub-millisecond
 cold starts, aggressive per-request resource caps.

The Workloads That Belong There

WorkloadWhy edge wins
Auth token verificationReject bad requests before they cross oceans
A/B routing / personalizationDecision latency IS UX
Request/response transformsHeader rewrites, image negotiation
API aggregation for mobileParallel fan-out from near the user
Bot filtering / WAF logicAttack mitigation at ingress
Real-time fan-outChat/presence relayed regionally
 pattern uniting them: SHORT, STATELESS, LATENCY-SENSITIVE.
 anything needing >50ms CPU or heavy state doesn't fit —
 see constraints below before falling in love.

The Constraints That Define It

 ✗ LONG CPU WORK:      CPU-time caps (ms to low seconds)
 ✗ HEAVY DEPENDENCIES: small bundles; limited native libs
 ✗ LOCAL DISK:         mostly none; storage is networked/KV
 ✗ TRADITIONAL DATABASES: connection pooling across 300 POPs
                        against central DBs = anti-pattern;
                        use HTTP APIs/caches/regional replicas
 ✗ STRONG CONSISTENCY: writes still need an authoritative region

 edge compute EXTENDS the architecture (fast paths + gateways);
 it does not REPLACE regions of record.

The Architecture Pattern

 [user] ──► [EDGE: auth, routing, personalization, cache mgmt]
                 │ allowed & cacheable → serve locally
                 │ needs truth

          [REGIONAL CORE: databases, transactions, workers]

 edge as intelligent filter + accelerator;
 core as system of record. most successful edge deployments
 are exactly this two-tier story.

Interview Framing

“Use edge computing for checkout?” tests constraint-awareness. Scored answer distinguishes layers: token validation and cart pricing DISPLAY at edge (fast reads), but payment AUTHORIZATION stays regional (consistency + compliance). Candidates who move everything to the edge fail; those who identify the fast-path subset pass. Name CPU/stateless constraints explicitly — that’s the depth signal.

My Private Notes

Notes are auto-saved locally to this device.