← Create New Paste

Designing an Image Upload and Thumbnail Pipeline: A System Design Interview Walkthrough

3 views
"Design the photo upload feature for a social app" is a popular system design prompt because it looks small but touches storage, queues, async processing, CDNs and failure handling. Here is a structure you can follow in a 45-minute round. 1. Clarify requirements first Ask a few questions before drawing anything: - What sizes do we need? For example a 150px thumbnail, a 600px feed image and the original. - How many uploads per day, and what is the average file size? (Say 20 million uploads/day at 3 MB each, about 60 TB of originals per day.) - How quickly must the thumbnail be visible after upload? A few seconds is usually acceptable. - Do we need content moderation, EXIF stripping, or format conversion (HEIC to JPEG/WebP)? Writing these numbers down early lets you justify later choices instead of guessing. 2. Keep large files off your app servers A common mistake is streaming the image through the API tier. Instead: 1. The client asks the upload service for a pre-signed URL. 2. The client uploads directly to object storage (S3, GCS or similar), optionally using multipart upload for large files. 3. Object storage emits an "object created" event, or the client calls a "complete" endpoint with the object key. This keeps the API stateless and cheap, and lets storage handle the heavy bandwidth. 3. Process asynchronously with a queue The completion event goes onto a message queue. A pool of image workers pulls jobs, downloads the original, validates it (real image, size limits, malware scan if required), strips location metadata, and produces each variant. Results are written back to object storage under predictable keys such as photos/{id}/w600.webp, and a metadata row is updated with status = ready. Points interviewers like to hear: - Idempotency: workers may receive the same job twice, so writing to deterministic keys makes retries safe. - Retries and dead-letter queue: corrupt files should not block the queue forever. - Autoscaling on queue depth: uploads spike in the evening and during events. 4. Serving Images are served through a CDN in front of object storage. Since variants are immutable, you can set long cache headers and use a new key if a photo is edited. Until processing finishes, the client can show a local preview or a blurred placeholder, so the user never stares at a blank square. 5. Data model and status A simple photos table (id, owner_id, original_key, status, created_at, variants) is enough. The status field (uploading, processing, ready, failed) drives the UI and lets you retry stuck jobs with a periodic sweeper. 6. Discuss trade-offs out loud - Pre-generate vs on-the-fly resizing: pre-generating is predictable; on-the-fly resizing at the CDN edge saves storage when you need many sizes. - Storage cost: move originals to colder storage after 30 days if they are rarely read. - Moderation: run it asynchronously and hide the photo if it is flagged, rather than delaying every upload. How to practise Say the design out loud with a timer, and force yourself to state the numbers and one trade-off per component. In the real interview, staying structured under pressure is often harder than the design itself. Tools like Linkjob AI (https://linkjob.ai) give real-time help during live job interviews and technical interviews, which can help you keep your structure when nerves kick in, but the reasoning above is what you need to own.
Created Nov 17, 2026 03:01 Expires Nov 17, 2027 03:01