Content Delivery and Edge Networking Questions
Serving content and computation close to users: CDN architecture, edge caching, cache-control and purge strategies, and edge computing versus centralized cloud processing. Covers origin shielding, geo-routing, and the tradeoffs of pushing logic to the edge for latency-sensitive workloads. Application-layer content distribution rather than raw network engineering.
Design an experiment to choose between two caching strategies (edge vs central) for a global user base when historical latency data is sparse. Include metrics, sampling plan, and rollback criteria for the experiment.
Sample Answer
Requirements & goals:
- Objective: decide whether edge caching (CDN/PoPs) or central caching (regional central cache close to origin) gives better user-perceived latency and cost for a global customer with sparse historical data.
- Success criteria: statistically significant improvement in user latency p50/p90/p99 without unacceptable cost increase or availability regressions.
Metrics (primary & secondary):
- Primary: real-user latency percentiles (p50, p90, p99) from client-side RUM and edge timing (DNS, connect, TTFB, download).
- Secondary: cache hit ratio, origin traffic (RPS, bytes), error rate (4xx/5xx), availability, cost per 100k requests, TTL eviction rate, geographic variance.
- Business metric guardrails: conversion rate or revenue-per-request if available.
Sampling & experiment plan:
- Stratify by region (NA, EU, APAC, LATAM, MEA) and device type (mobile/desktop). Because historical data is sparse, ensure equal representation across strata.
- Randomized A/B (between-subjects): route a user (or cookie/device-id) consistently to one strategy for experiment duration. Use sticky identifiers to avoid cross-contamination.
- Traffic allocation ramp: 1% -> 5% -> 20% -> 50% over 24–72 hours per step, observing metrics and safety signals at each step. Hold final allocation for at least one week to capture diurnal and weekly patterns.
- Sample size & run length: perform power calculation using conservative effect size (e.g., 5–10% p90 latency improvement). If baseline variance unknown, run initial pilot (1–2 days at 5–20%) to estimate variance, then compute required users per stratum.
- Measurement methods: combine RUM (client-side) for true user experience and synthetic probes from PoPs for controlled measurement. Instrument server logs with request tags, enable tracing for slow paths.
Analysis plan:
- Compare p50/p90/p99 per region with confidence intervals (bootstrap) and perform hypothesis tests per metric with correction for multiple comparisons (Benjamini-Hochberg).
- Evaluate cost delta and hit-ratio tradeoffs; compute cost per millisecond improvement.
- Inspect tail latency causes via tracing; check origin load reduction.
Rollback & safety criteria:
- Automatic rollback triggers:
- p99 latency increases by >20% or exceeds SLO for any major region for >15 minutes.
- Error rate (5xx) increases >2x baseline or absolute >0.5% sustained 10 minutes.
- Origin RPS spike causing system stress (CPU/memory thresholds) or cost overruns beyond predefined budget cap.
- Business guardrail drop: conversion falls >5% (if measurable) sustained for a day.
- Manual rollback: engineering on-call or experiment owner can halt if unexplained anomalies observed.
- Implementation: feature-flag rollout with immediate kill switch, health dashboards, automated alerts, and playbook for rollback steps (flip flag, re-route traffic, invalidate caches if needed).
Operational notes & trade-offs:
- Ensure consistent cache keys and headers between strategies to avoid cache-miss skew.
- TTL and consistency: test with production-like TTLs; simulate cache invalidation patterns.
- If global users are compliant-sensitive, ensure routing respects data locality and legal constraints.
- If variance remains high after pilot, consider geo-targeted permanent strategy: edge for regions with high latency variance, central where origin proximity matters and cost is sensitive.
This design provides statistically sound comparison, regional sensitivity, business guardrails, and safe rollback mechanisms suited for a solutions-architect level decision.
Design an edge-caching strategy for a CDN in front of APIs that serve mutable resources like user profiles. Address cache key design, TTLs, invalidation strategies (purges vs surrogate keys), signed URLs, private vs public caching, and how to maintain data correctness while maximizing cache hit ratio and reducing origin load.
Sample Answer
Requirements:
- Low read latency for user-profile API, high cache hit ratio, strong correctness for recent updates, support public and private fields, scalable invalidation, minimal origin load.
High-level approach:
- Use CDN edge layer with origin being API + authoritative data store. Combine short/long TTLs, surrogate keys, and selective client-side cache-control for private data; employ signed URLs/tokens for access control.
Cache key design:
- Primary key = GET URL path + query normalized + Accept-Language + variant headers (e.g., viewport) + Vary (minimal). Append "cache-namespace" such as profile:{user_id}:v{profile_version} when available.
- For private fields, separate endpoints (e.g., /profiles/{id}/public vs /profiles/{id}/private) so public responses are cacheable CDN-wide; private responses are user-scoped and include Authorization-bound keys.
TTLs:
- Public profile: moderate TTL (30s–5m) depending on update frequency, with stale-while-revalidate (SWR) = TTL*5 to serve stale while asynchronously refreshes.
- Strongly dynamic fields (last-active): short TTL (0–10s) or set Cache-Control: no-store if correctness required.
- Private responses: short TTL (0–60s) plus must-revalidate or no-cache depending on sensitivity.
Invalidation strategies:
- Surrogate keys (recommended): when updating user profile, origin issues an API to CDN to tag surrogate key profile:{user_id}; CDN invalidates all edges with that surrogate key (fast, targeted). Use soft-purge (mark stale) + async background refresh to avoid origin stampede.
- Purges (full URL): use sparingly for emergency full purges; costly at scale.
Signed URLs / Tokens:
- Use signed cookies or headers for private endpoints; CDN validates signature and caches only when token identifies same principal and has consistent cache key (e.g., include hashed user_id in cache key). Prefer short token TTLs and include token metadata in surrogate-key tagging for invalidation.
Private vs Public caching:
- Split endpoints by sensitivity. Public endpoints are globally cacheable. Private endpoints are edge-cacheable only when token-bound and cache key includes principal ID — otherwise bypass CDN or mark as private with CDN edge-storage but not shared.
Maintaining correctness & maximizing hit ratio:
- Use versioned cache keys: embed profile_version or ETag in cache-key when available to allow long TTLs safely.
- Use stale-while-revalidate and background revalidation (edge workers) to serve stale and refresh proactively.
- Coalesce origin requests with request collapsing / locking to prevent stampedes.
- On writes, update datastore, increment profile_version, then issue surrogate-key purge and publish cache-invalidation events to CDN and to edge-workers for pre-warm of popular profiles.
Operational considerations:
- Monitor hit ratio, origin RPS, stale serve rate, invalidation latency.
- Rate-limit invalidations; batch surrogate key invalidations.
- Trade-offs: surrogate keys add complexity but scale; short TTLs increase origin load but improve correctness; SWR + background refresh balances both.
This design maximizes edge reuse for public data, keeps private data secure and scoped, and uses surrogate keys + versioning + SWR to preserve correctness while reducing origin load.
Global website needs cache invalidation and origin failover. Design CDN cache invalidation strategies for content updated frequently (e.g., product pages) and propose an origin failover plan if the primary origin becomes unavailable. Consider consistency, performance, and cost.
Sample Answer
Situation & goal: We need a global CDN strategy that keeps frequently-updated pages (product pages, pricing, inventory) reasonably consistent while minimizing latency and cost, and provides robust origin failover when the primary origin is down.
Cache invalidation strategy (consistency vs cost tradeoffs)
- Cache-control + short TTLs: Serve product pages with Cache-Control: public, max-age=60–300s plus stale-while-revalidate to reduce origin load while keeping ~1–5 min freshness.
- Conditional requests: Use ETag/Last-Modified so CDN/origin can validate quickly (304) instead of full payloads.
- Origin-push notifications (recommended): On product update, publish an invalidation event to CDN via API or a pub/sub webhook (regional edge invalidation). Use targeted invalidation (by URL or surrogate-key) rather than full-pop to save cost.
- Surrogate-keys / tagging: Attach keys like product:{id} to responses so you can invalidate all related objects with a single API call (e.g., update product image + page).
- Progressive invalidation: First invalidate edge POPs closest to user segments affected, or invalidate low-traffic POPs less aggressively to save cost.
- Read-through cache for dynamic fragments: Keep heavy static fragments cached long, assemble pages at edge using short-lived dynamic tokens (Edge Side Includes or edge compute) to balance performance and freshness.
Origin failover plan
- Health checks + routing: Configure active health checks from CDN to primary origin; on failure, switch to secondary origin via CDN origin pool or via DNS with short TTL and health-aware load balancing.
- Tiered origins: Primary origin (write-enabled) + read-replica origin(s) in multiple regions. Serve reads from replicas; writes go to primary via API gateway.
- Stale-while-revalidate + serve-stale-on-error: If origin is down, allow CDNs to serve stale cached content (configurable TTL) to preserve availability; display a banner indicating potential stale data.
- Data sync strategy: Use asynchronous replication from primary to read replicas with minimal lag (streaming/event-driven). For critical consistency (inventory), implement a fallback check: when serving stale content for checkout, validate inventory at checkout time via a direct origin call to a highly-available inventory microservice.
- Failback: Once primary recovers, run reconciliation jobs and invalidate affected keys (surrogate-key) to ensure freshness.
Operational & cost considerations
- Minimize global full invalidations; prefer surrogate-key and targeted invalidations.
- Monitor metrics: cache hit ratio, origin-request rate, invalidation count/cost, failover frequency.
- Safety valves: rate-limit automated invalidation requests; batch updates for high-volume changes (queue + debounce).
- Playbooks & testing: Regularly run chaos tests for origin failover and rehearse invalidation flows.
This approach balances consistency (ETag, short TTLs, targeted invalidation), performance (edge caching, stale-while-revalidate, read replicas), and cost (avoid full purges, use surrogate-keys and short TTLs strategically).
Explain latency and consistency trade-offs between client-side caching, CDN edge logic, and server-side rendering for a global design system delivering personalized UI components. Prepare a short narrative for CTOs and a two-bullet summary suitable for VPs highlighting business impact.
Sample Answer
Narrative for CTO (technical but strategic):
For a global design system that serves personalized UI components, latency and consistency are a trade space across three layers.
-
Client-side caching (in-memory, localStorage, service worker): Lowest interaction latency because assets and precomputed personalization live closest to the user. It enables instant UI render and offline support. The trade-off is staleness risk — user-specific variations (feature flags, A/B) and global style updates propagate slowly unless you implement validation (ETags, TTLs, cache-busting). Complexity increases when invalidation must be targeted per-user.
-
CDN edge logic (edge compute, dynamic edge rendering): Moves personalization logic closer to geographic users and reduces RTTs compared to origin. It supports fast, regional consistency windows and can assemble component fragments at the edge using short-lived feature-state, cookies, or JWTs. Trade-offs: limited compute/memory constraints, higher operational complexity, and potential divergence if origin state changes faster than edge invalidation TTLs. Edge is ideal when you need sub-100ms regional responses and controlled consistency windows.
-
Server-side rendering (SSR from origin or regional clusters): Provides the strongest point-in-time consistency because rendering uses canonical server state on each request; great for guaranteeing correct personalization and up-to-the-minute component variants. Latency is higher when origin is distant; mitigations include regional SSR clusters, global load balancing, and caching of non-personal parts. SSR also simplifies security (no sensitive logic in client) but increases origin load and cost.
Recommended hybrid pattern: cache static design tokens and base component bundles in CDN with long TTL; compute ephemeral personalization at the edge for common variants; fall back to SSR for high-sensitivity or real-time personalized pages. Use versioned assets + incremental invalidation, ETag/If-None-Match, and a user-segment-aware cache-key strategy. Instrument with metrics (p95 latency, cache hit ratio, stale-read rate) and a fast invalidation pipeline for critical UX fixes.
Two-bullet summary for VPs (business impact):
- Reduce perceived latency and increase conversions by serving static assets from CDN + edge-assembled personalization (fast ROI; low p95 latency), while protecting brand consistency with versioned assets and targeted invalidation.
- Ensure correctness where it matters (billing, legal, high-trust UX) via SSR or origin-validated renders—accepting higher cost/latency for compliance and trust, and mitigate with regional rendering and selective caching to control spend.
A third-party CDN in a PoC fails to meet latency targets in several regions. Prepare a client-facing recommendation memo that quantifies trade-offs (cost, complexity, latency), lists realistic alternative options (multi-CDN, edge compute, caching strategy changes), and proposes a phased remediation plan with metrics to validate improvement.
Sample Answer
Executive summary
During the PoC we observed the selected third‑party CDN missing latency targets in Regions A, B and C — median p95 origin-to-client times were 220–480 ms vs. target of ≤150 ms. Below I quantify trade-offs, propose realistic alternatives, and give a phased remediation plan with measurable validation criteria.
- Quantified trade-offs (cost / complexity / expected latency)
- Continue with current CDN and optimize caching
- Cost: Low (tuning only)
- Complexity: Low
- Likely p95 improvement: 10–25% (expected p95 ≈ 170–400 ms) — may still miss targets in Regions B/C
- Multi‑CDN (primary + regional providers)
- Cost: Medium–High (dual contracts, DNS/RTT steering)
- Complexity: Medium (routing, failover, analytics)
- Expected p95: ≤120–160 ms in most regions
- Edge compute (move compute/SSG to edge + CDN)
- Cost: Medium–High (platform fees, engineering)
- Complexity: High (app refactor, CI/CD)
- Expected p95: ≤80–120 ms for dynamic content; best UX gains
- Hybrid: Multi‑CDN + Edge
- Cost: High
- Complexity: High
- Expected p95: ≤70–110 ms, highest resilience
- Realistic options to evaluate
- Option A (fast, low cost): Caching strategy changes + CDN config tuning (cache TTLs, stale‑while‑revalidate, compression, TCP/TLS optimizations, regional POP pinning)
- Option B (balanced): Multi‑CDN with global traffic steering + enhanced monitoring (RUM + active probes)
- Option C (strategic): Migrate dynamic hotspots to edge compute (Cloudflare Workers, Fastly Compute@Edge, AWS CloudFront+Lambda@Edge) + multi‑CDN for origin distribution
- Phased remediation plan (6–12 weeks)
Phase 0 — Validation (1 week)
- Baseline: Collect RUM, synthetic pings, p95/p50, error rates, byte hit ratio per region.
- Success metrics captured in dashboard.
Phase 1 — Low‑effort tuning (2 weeks)
- Implement caching improvements (cacheable headers, SWR), enable compression, optimize TLS settings, reduce cookie scope.
- Validate: 15%+ reduction in p95 and 10% increase in cache HIT ratio. If p95 ≤150 ms in target regions → STOP.
Phase 2 — Multi‑CDN pilot (3–4 weeks, parallel)
- Contract with 1 regional CDN for Regions B/C. Implement DNS steering + health checks.
- Validate: p95 ≤150 ms in pilot regions for 90%+ of requests, failover <2s, no regression in other regions.
Phase 3 — Edge compute pilot (4–6 weeks, parallel or sequential)
- Move 1 high‑value dynamic flow to edge (SSR/edge cache).
- Validate: p95 ≤120 ms for that flow, reduced origin CPU/load by 30%, error rates at parity.
Phase 4 — Rollout & ops (ongoing)
- Full rollout of chosen combination, SLOs: p95 ≤150 ms regionally, availability ≥99.9%, cache hit ratio ≥85% where applicable.
- Implement automated traffic steering, synthetic monitoring, and RUM dashboards.
- Quarterly review for contractual renegotiation and cost optimization.
- Risks and mitigations
- Increased vendor complexity: mitigate with orchestration layer (traffic manager) and runbook.
- Cost overrun: pilot first, measure Cost-per-Request and ROI (latency => conversion uplift).
- Implementation delay: scope minimal pilot artifacts to reduce refactor.
Recommendation
Start with Phase 1 immediately (low cost, fast). Parallelize a Multi‑CDN pilot for Regions B/C (Phase 2). If latency still misses targets or business requires best possible UX, run an edge compute pilot (Phase 3). Deliverables within 8–12 weeks with clear pass/fail metrics at each phase.
Next steps
- Approve Phase 1 budget and measurement dashboard (1 week)
- Approve pilot budget for one regional CDN (Phase 2)
- Schedule architecture/engineering kickoffs
Metrics to report at each checkpoint: RUM p50/p95, synthetic p95, cache hit ratio, origin request rate, Cost-per-100k requests, error rate.
Unlock Full Question Bank
Get access to all 7 Content Delivery and Edge Networking interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.