Design an image hosting service (like Imgur)
medium 50 minUpload a picture, get a link at once, and let the whole world look at it.
Grow the design
Start with the smallest system that works. Change it only when something breaks.
Version by version
From one box to the full system
Seven versions
Version 1: One service, one database
Forced by: Upload and view.
- What changes
- The service saves the file on its disk, makes the sizes in the request, stores a record in PostgreSQL and serves the files.
- What it costs
- Simple. One machine to back up.
- What breaks next
- The disk. 14 TB a day fills it in hours, and a lost disk loses pictures. For a club's photos, stop here.
Say: Let me get upload and view working, then see which target it misses.
Architecture
High-level design
The whole system
Five layers
- 1
Edge
CDN on img.example: no cookies, long shared caching, sizes and formats from a fixed list.
- 2
Gateway
api.example: TLS, sign-in, limits, firewall, routing.
- 3
Services
Upload, image, album, user and a thin social and search part. Start as one program with clear modules; split upload first if its load differs.
- 4
Processing
Queue, sandboxed workers, checks, review.
- 5
Data
Object storage, PostgreSQL, Redis, search index, column store.
Flows
The flows that matter
Flow 1: upload
Flow 2: process
Flow 3: view
Flow 4: make an album
Life of an image