The interview problem

Practice prompt

Serve resized product images through a CDN without allowing arbitrary transformation URLs to exhaust compute and cache storage.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume immutable source versions and a small approved transform vocabulary. Canonicalize dimensions, format and crop parameters; include source version and transform version in cache keys. Authorize private-source access before cache lookup. Coalesce concurrent misses for a variant and run decoders in resource-bounded workers. Cache only successfully validated outputs; publish a clear failure or approved fallback if decoding fails.

2. Trace the design or derivation

Validate source and parameters
  → derive canonical key
  → cache lookup
  → transform once
  → publish

The cache key should include source content version, transform implementation version and every output-affecting option. Exclude arbitrary remote URLs unless a separate fetch policy validates them. Coalesce concurrent misses for one variant and reject pathological dimensions before decoding, because output byte size alone does not bound decode memory.

3. Calculate the example

Ten million source images with six variants averaging 50 KB would occupy about 3 TB if eagerly materialized. If only 20% of sources need all six, their corresponding variant payload is about 600 GB. Arbitrary width values can destroy that saving by creating unbounded distinct cache keys.

4. Failure cases and trade-offs

A small compressed image can decode into an enormous pixel buffer. Source URL fetching can cross unwanted network boundaries; use approved origins. Variant authorization must not be bypassed by a shared cache key. Precomputation provides predictable latency but stores unused results; lazy generation saves space but needs burst protection.

5. Validation, follow-ups and self-review

Test equivalent parameter ordering, malicious dimensions, repeated concurrent misses and source replacement. Measure decode memory and cold/warm latency. Follow-up: what happens when a crop algorithm changes? Reward canonical keys, immutable provenance and bounded transformation work.

Sources and related practice

Technical reference: developers.cloudflare.com — Image transformation parameters as a concrete variant-service reference.

Source publication/update: Updated May 26, 2026. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Invalidate mutable content across edge caches; Gate low-quality uploads before downstream inference.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.