System Design · Senior · Question 15 of 75
How would you design serving user images in different sizes?
- ✓Correct answer: Store the original, generate sizes and formats on demand and cache on a CDN
- 2Pre-generate every possible size for every device at upload time
- 3Serve only the original and scale it in the browser with CSS
Explanation
A transformation service (in-house or cloud) creates a variant from width and format URL parameters and puts it into the CDN cache. The set of allowed sizes is limited to avoid endless variants and to prevent attacks on the service.