Design an Image Resizing Service
MediumSystem design · Media
Design an image service that accepts uploads and serves resized and reformatted variants through URLs. Scale: 20K image requests/s at the edge with a cache hit rate above 98%, so about 400 renders/s reach origin. Cover validating uploads, constraining the transform space (presets or signed URLs) so it cannot be abused, cache keys and CDN behaviour, request collapsing, eager versus lazy generation, format negotiation, and isolation of the render workers.
Requirements
- Reject malformed or oversized uploads and decode untrusted images in an isolated, resource-limited worker
- The set of renderable variants is bounded by presets or signed parameters
- Variants are cached by normalised key; many concurrent misses cause one render
- Support modern formats by negotiation without fragmenting the cache; strip metadata and apply orientation