← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 015 · Databases and storage

Design a File Upload Service

Easy 35 min

Design a service that other products in a company use to accept file uploads: contracts, videos, design files. Files can be up to 2 GB, and users are often on slow or flaky connections. After upload, every file is scanned for malware before anyone can download it. The service handles 40 million uploads a month and serves 1,000 API requests per second at peak (starting uploads, checking status, requesting download links). File bytes should not flow through the API servers.

Functional requirements

  • Start an upload and send file bytes, resuming after a dropped connection
  • Scan each file for malware before it becomes downloadable
  • Fetch a file's metadata and status (uploading, scanning, ready, rejected)
  • Get a time-limited download link for a ready file

Non-functional requirements

  • API calls answer in under 300 ms at p95
  • A completed upload is never lost
  • Infected files are never served

Constraints and scale

  • Files up to 2 GB, 20 MB on average
  • 40 million uploads per month, about 800 TB stored per year
  • 1,000 API requests per second at peak

You will practise

  • Keep large payloads off application servers with presigned URLs and multipart uploads
  • Separate file bytes (object storage) from metadata (database)
  • Run slow processing such as scanning asynchronously with a queue and workers
Show 2 hints
  1. A 2 GB upload can take an hour on mobile. Should an API server hold that connection open?
  2. How does the scanner find out a new file has arrived?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • The virus scanner falls behindA partner bulk-uploads 2 million files in an hour. Scan jobs pile up and files sit in 'scanning' for hours.

Run them from the workspace once your design is in place.