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
A 2 GB upload can take an hour on mobile. Should an API server hold that connection open?
How does the scanner find out a new file has arrived?