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.
When should you use edge computing or a CDN to reduce read latency for game state? Describe benefits, limitations, and trade-offs including caching staleness, cost, consistency challenges, and operational complexity.
Sample Answer
Use edge computing or a CDN for game-state reads when low read latency and geographic distribution are primary constraints and the state is either largely read-mostly or can tolerate some staleness. Typical scenarios: leaderboards, matchmaking queries, avatar/asset metadata, session discovery, and non-authoritative game state (e.g., cosmetic info).
Benefits:
- Lower latency and jitter by serving reads from PoPs close to players.
- Reduced origin load and improved scalability during spikes.
- Better user experience in global deployments; predictable tail latency.
Limitations & trade-offs:
- Caching staleness: CDNs/edges introduce time/validity windows (TTL, cache-control). For frequently-updated authoritative state (player positions, game physics) staleness is unacceptable.
- Consistency: Edges are eventually consistent; you must design for stale reads (versioning, ETags, read-after-write patterns, cache-bypass on critical paths).
- Cost: CDN/edge egress and per-request pricing can be higher than centralized reads; need to model traffic patterns and cache hit rates.
- Operational complexity: Deploying logic at edge (serverless functions, edge caches) adds CI/CD, telemetry, debugging, and security considerations.
Practical patterns:
- Hybrid: keep authoritative writes central; serve read-heavy, tolerant data from edge with short TTLs and invalidation hooks on updates.
- Cache-busting for critical reads: use signed URLs, versioned keys, or explicit purge on state change.
- Consistency strategies: client-side validation (sequence numbers), read-through cache with origin fallback, or use CRDTs/replicated stores for eventually-consistent state that tolerates merges.
As a solutions architect, pick edge/CDN when read SLA improvements outweigh increased cost and complexity, and enforce clear data classification (authoritative vs cacheable) plus monitoring, purge/invalidation paths, and fallbacks for cache misses.
A client serves large static assets and occasional dynamic content to a global audience. Describe how you would use a content delivery network (CDN) to improve latency and reduce origin load. Include which assets to cache at the edge, recommended cache-control header strategy, approaches for invalidation or cache-busting after deployments, and how to handle personalized dynamic content.
Sample Answer
Requirements & goal: Reduce latency for a global audience and lower origin load while still supporting occasional dynamic and personalized content.
High level approach:
- Put a CDN in front of the origin (global POPs + origin shielding). Let the CDN serve static assets from edge caches and selectively cache dynamic responses where safe.
Which assets to cache at the edge:
- Long-lived static assets: images, fonts, JS/CSS, video segments — cache aggressively.
- Static HTML pages that change rarely — short TTLs or stale-while-revalidate.
- API responses that are safe to share (public, idempotent) — TTL based on data volatility.
- Don’t cache responses that include private user data (authentication tokens, user-specific data) unless you fragment.
Recommended Cache-Control strategy:
- Static immutable assets: Cache-Control: public, max-age=31536000, immutable
- Versioned static assets (content-hashed filenames): long max-age as above.
- Semi-dynamic content: Cache-Control: public, s-maxage=60-300, stale-while-revalidate=30
(s-maxage for shared caches; s-maxage overrides max-age for CDN) - Private/personalized: Cache-Control: private, no-store or max-age=0
- Always set Vary headers thoughtfully (e.g., Vary: Accept-Encoding). Avoid Vary: Cookie unless needed.
Invalidation / cache-busting:
- Preferred: asset versioning (content hashing in filenames) — reliable, simple, zero-downtime.
- For other resources: CDN cache purge API integrated in CI/CD to purge paths or surrogate keys after deploy.
- Use surrogate keys/tags to purge groups efficiently rather than blanket purges.
- For time-sensitive updates: use short TTL + stale-while-revalidate to avoid origin spikes.
Handling personalized dynamic content:
- Use cache segmentation:
- Edge compute (Workers/Lambda@Edge) to assemble cached fragments + user-specific bits (Edge Side Includes or fragment caching).
- Cache anonymous/common parts at edge; fetch personalization from origin or an edge function.
- Use cookie-less cache keys where possible (encode profile in tokens only when safe), or use header-based keys for known segments.
- For authenticated API endpoints: keep responses private or cache per-user key if necessary (careful with memory and invalidation).
- Consider stale-if-error to serve slightly stale personalized pages during origin failures.
Operational considerations:
- Enable Brotli/Gzip and TLS termination at edge.
- Origin shielding and rate-limiting to protect origin from purge storms.
- Monitor cache hit ratio, purge frequency, and origin traffic; alert on cache miss spikes.
- Integrate CDN invalidation into deployment pipeline and document TTL/purge policies.
Trade-offs: aggressive caching reduces origin load but increases complexity for invalidation; versioned assets are simplest and safest for static content. Edge compute adds flexibility for personalization with modest additional cost.
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.
Describe how a CDN reduces latency for static and dynamic content. Explain cache-control headers, TTLs, stale-while-revalidate, origin shielding, and strategies for cache invalidation. Include how to handle authenticated or personalized content at the edge and principles to decide what to cache.
Sample Answer
A CDN reduces latency by serving content from edge POPs geographically close to users (shorter network RTTs) and by offloading origin servers so fewer round-trips and less CPU work are needed. For static content (images, JS, CSS) CDN caches at edge with long TTLs; for dynamic content CDNs may cache full responses, fragments, or use techniques like edge-side includes or response streaming.
Cache-Control headers and TTLs:
- Cache-Control: public/private, max-age (seconds), must-revalidate, no-cache.
- max-age sets TTL at caches; shorter for dynamic resources, longer for static assets.
- private prevents shared caches from storing user-specific responses.
stale-while-revalidate and stale-if-error:
- stale-while-revalidate: serve stale content immediately while asynchronously refreshing from origin — reduces latency on miss.
- stale-if-error: serve stale if origin unavailable.
Origin shielding:
- A single shield POP between edges and origin reduces origin load and cache-miss storms by consolidating origin requests.
Cache invalidation strategies:
- Time-based TTLs, cache-busting (file fingerprinting / content-hash in filenames), soft purges (mark stale, background refresh), hard purges (API purge) for urgent removes, and graceful rollouts.
Handling authenticated/personalized content:
- Avoid caching user-specific responses at shared caches. Use cookies/authorization headers to vary (Vary header) and short TTLs if caching at edge is acceptable.
- Prefer edge-side personalization: cache a base template at edge and run lightweight personalization (A/B data or user-specific fragments) in edge compute (Cloudflare Workers, Lambda@Edge) using signed tokens.
- Use tokenized requests to origin or cache per-session keys only when secure and low-cardinality.
Principles to decide what to cache:
- Cacheability: static, high-read low-write, low sensitivity to staleness.
- Cost/latency benefit: high size or high request-rate assets yield biggest wins.
- Mutability and security: avoid caching highly personal, frequently changing, or sensitive data.
- Use fingerprinting for immutable assets; short TTLs + stale-while-revalidate for semi-dynamic content; edge compute for safe personalization.
Unlock Full Question Bank
Get access to all 14 Content Delivery and Edge Networking interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.