KatInterview

Chunked Upload Pipeline with Async Processing

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsasync-processingfile-upload

Last updated

Design a system that handles large file uploads with resumability, processes them through async validation and transformation stages, and notifies users of completion.

Problem Context

You're building a platform where users upload large media files—videos and images ranging from 100MB to 5GB. After upload, each file must pass through multiple processing stages: format validation, security scanning, transcoding to multiple resolutions, and automated content analysis. Your system must handle unreliable network conditions, coordinate these processing steps, and inform users when their content is ready.

Core Requirements

Your design should support:

  • Chunked resumable uploads: Break large files into pieces that can be uploaded independently and resumed after network failures
  • Direct storage writes: Route file data directly to object storage without saturating application servers
  • Duplicate request handling: Ensure that retries and duplicate requests don't trigger redundant processing
  • Multi-stage processing: Orchestrate independent analysis steps with proper ordering and parallelization
  • User notifications: Deliver timely updates to clients about processing status

Scale Expectations

  • Volume: 20 million upload sessions daily (~250/sec average, 1,000/sec peak)
  • File characteristics: 200MB average, 5GB maximum
  • Availability: 99.99% uptime target, 99.999999999% durability for stored files
  • Processing time: Complete analysis within 3–5 minutes for typical 500MB videos

Design Scope

Your solution should address:

  1. Upload mechanics: API endpoints, chunking strategy, and how clients interact with storage
  2. State tracking: Data models for upload progress, file metadata, and task status
  3. Processing pipeline: Architecture for coordinating validation, transcoding, and analysis workers
  4. Reliability patterns: How you prevent data loss, handle failures, and ensure idempotency
  5. Client updates: Mechanism for pushing status changes back to users

Be specific about protocols, data structures, and failure scenarios.

Hints

Hint 1

Calculate bandwidth requirements to understand why application servers can't proxy the data

Hint 2

Consider how to make chunk uploads and completion requests safely retryable

Hint 3

Think about which processing steps must complete sequentially vs. which can run in parallel

Hint 4

Design for worker failures—tasks may be executed more than once