System Design••20 min read
System Design: Image CDN Architecture
Designing an image CDN that can handle millions of requests requires careful consideration of caching, storage, and transformation strategies. Let's walk through the architecture.
Requirements
Functional Requirements
- Upload images via API
- Transform images on-the-fly (resize, crop, format conversion)
- Serve images globally with low latency
- Support for multiple resolutions and formats
Non-Functional Requirements
- Handle 10M+ requests per day
- P99 latency under 100ms
- 99.9% availability
- Cost-effective storage
High-Level Architecture
The system consists of several key components:
- **Upload Service**: Handles image uploads and storage
- **Transform Service**: Processes image transformations
- **CDN Layer**: Global edge caching
- **Origin Storage**: Durable storage for original images
Storage Strategy
For storage, we use a tiered approach:
- **Hot storage**: Recently accessed images on SSDs
- **Warm storage**: Standard object storage (S3)
- **Cold storage**: Glacier for rarely accessed archives
Transformation Pipeline
Images are transformed on-demand using a URL-based API. The transform service parses the requested transformations, checks if a cached version exists, and if not, fetches the original and transforms it.
Caching Strategy
Multi-layer caching is essential:
- **Browser cache**: 1 year for immutable URLs
- **CDN edge cache**: 30 days
- **Transform cache**: 7 days for processed images
Scaling Considerations
To handle peak traffic:
- Horizontal scaling of transform workers
- Pre-warming popular images
- Graceful degradation for non-critical transforms
This architecture can scale to handle billions of image requests while maintaining low latency and reasonable costs.
STAY UPDATED
Get notified about new photos and articles. No spam, unsubscribe anytime.