← Lessons

quiz vs the machine

Platinum1720

System Design

The Photo Sharing Design

Uploading, storing, and serving images at scale with object storage and a CDN.

5 min read · advanced · beat Platinum to climb

The shape of the problem

A photo sharing service lets users upload images and view feeds of them. Photos are large and immutable, and reads vastly outnumber writes, so storage and delivery dominate the design.

Upload and storage

  • The client often uploads directly to object storage using a pre signed url, so image bytes skip the application servers.
  • A metadata record stores the photo id, owner, caption, timestamp, and a reference to the stored object.
  • The original is processed into several sizes, a thumbnail, a feed size, and a full view.

Serving images

  • Images are served through a content delivery network so bytes come from an edge near the viewer.
  • The right size variant is chosen per surface, a small thumbnail in a grid, a larger one when opened.
  • Because photos are immutable, they cache aggressively, often forever.

Feeds and metadata

  • Feeds store only photo ids and references, hydrating metadata and image urls at read time.
  • Metadata lives in a database keyed by id, separate from the heavy image bytes.

Key idea

A photo sharing service uploads images straight to object storage, keeps small metadata separate in a database, processes multiple size variants, and serves immutable images from a CDN near each viewer.

Check yourself

Answer to earn rating on the learn ladder.

1. Why upload image bytes directly to object storage?

2. Why process a photo into several size variants?

3. Why can photos be cached aggressively at the edge?