Design a Resumable, Token-Secured File Transfer Platform
System DesignModel answerLast updated
Design a high-throughput file transfer service that handles multi-gigabyte uploads and downloads with scoped token auth, revocation, chunk integrity, and bounded proxy memory.
Context
A regulated data exchange platform needs to move large files — compliance reports, audit archives, and bulk transaction exports — between internal services and external partners. Files range from a few hundred megabytes to 50 GB. Transfers happen over public internet connections that are occasionally unreliable, and every access must be auditable and revocable.
You are asked to design this system end to end.
What You Need to Support
Transfer capabilities
- Clients must be able to upload and download files up to 50 GB.
- If a transfer drops mid-way, the client must be able to pick up from the last successfully transferred chunk rather than restarting from the beginning.
- Chunks are typically 8–64 MB each.
Access control
- Issue short-lived, cryptographically signed tokens that encode who the caller is, which resource path they can access, what actions they can take (
read/write), and when the token expires. - Support rotating signing keys without dropping live traffic.
- Support immediate revocation of a specific token or all tokens for a given user.
Integrity
- Detect corruption or tampering at both the chunk level and the whole-file level using checksums (e.g., SHA-256).
Memory discipline
- Any API gateway or proxy that carries bytes must operate with O(1) memory per active connection, not buffer entire files or chunks.
Non-Functional Targets
| Dimension | Target |
|---|---|
| Concurrent active streams | 5,000 |
| Availability | 99.99% |
| Token validation overhead | < 5 ms per request |
| Encryption | TLS 1.3 in transit, AES-256 at rest |
| Audit logs | Immutable, covering every access and policy decision |
Scale Assumptions
- 100,000 file transfers per day, average size 500 MB, peak 50 GB.
- Aggregate peak bandwidth: ~40 Gbps.
What Is Expected
Walk through your design covering:
- Token format, validation, and revocation — how you keep auth fast while still supporting immediate revocation.
- Transfer workflow and API shape — how a client initiates, uploads chunks, resumes after failure, and finalizes.
- Data plane architecture — direct-to-storage (pre-signed URLs) vs. proxy streaming, and when you would choose each.
- Integrity verification — chunk-level and file-level, including what happens asynchronously after the final chunk lands.
- Failure handling — idempotent retries, out-of-order chunk arrival, and mid-transfer revocation.
Call out trade-offs and explain the choices you would make and why.
Hints
Hint 1
Start by sizing the system — compute daily byte volume, per-stream bandwidth, and what happens to proxy memory if you buffer an entire chunk per connection. The numbers will motivate most of your architectural choices.
Hint 2
Token validation latency under 5 ms rules out a round-trip to a central auth server on every request. Think about what you can verify locally and what state you absolutely must check remotely, then design the revocation path around that constraint.
Hint 3
The pre-signed URL and streaming proxy approaches are not mutually exclusive. Consider what property of a tenant's policy should determine which path their traffic takes, and make that a first-class configuration option.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Size the System First
Run the numbers before touching architecture — they constrain nearly every decision.
| Metric | Value |
|---|---|
| Daily data volume | 100K × 500 MB ≈ 50 TB/day |
| Average throughput | ~580 MB/s ≈ 4.6 Gbps; design for 40 Gbps peak |
| Bandwidth per stream | 40 Gbps ÷ 5,000 ≈ 8 Mbps |
| Parts per 50 GB file | 50 GB ÷ 64 MB ≈ 800 parts (well within S3's 10,000-part limit) |
| Proxy memory — buffering full chunks | 5,000 × 64 MB = 320 GB — clearly unacceptable |
| Proxy memory — 64 KB rolling buffers | 5,000 × 64 KB ≈ 320 MB — this is the O(1) target |
The memory calculation alone tells you that any proxy in the data path must stream with fixed-size buffers, never accumulate a full chunk in RAM.
2. Architecture: Separate Control from Data
Split the system into two planes.
Control plane — three stateless services:
- Auth service: issues tokens, publishes the public JWKS endpoint, manages revocation state.
- Transfer service: authorizes requests, creates upload/download sessions, tracks the part manifest in Postgres, and generates scoped pre-signed part URLs.
- Audit pipeline: every policy decision and storage event writes to Kafka, which drains into append-only, Object Lock–protected storage (WORM).
Data plane — two modes, chosen per tenant policy:
- Direct path (default): clients PUT and GET bytes straight to object storage using short-lived pre-signed URLs the transfer service generates. No bytes touch your fleet. This removes 40 Gbps of load at the cost of weaker inline control.
- Proxy path (inspection-required tenants): a Go or Envoy streaming proxy fleet carries bytes. It reads in 64 KB buffer increments, hashes incrementally, applies TCP backpressure, and writes onward to object storage without ever holding more than one buffer per connection. This gives you DLP/malware scanning and truly immediate revocation, at the cost of bandwidth and an extra failure domain.
The right answer is hybrid — tenant policy flags which path their traffic takes. Surfacing this as a config option rather than a binary architecture choice is what separates a strong answer from an average one.
3. Token Design and Fast Revocation
Format: Use PASETO v4.public or an asymmetric JWT (ES256/EdDSA). Avoid symmetric JWTs in a multi-tenant system — a compromised key forges tokens for every tenant. If you use JWT, pin the algorithm server-side and reject none and any HMAC variant.
Payload claims:
{ sub, tenant_id, res: "/tenantA/exports/2024/*",
act: ["write"], exp: now+10m, iat, jti, kid, aud: "file-transfer" }
Keeping validation under 5 ms: verify signatures in-process against a JWKS cached in memory, refreshed in the background. An ECDSA verify takes ~0.1 ms — no network round-trip on the hot path. On an unknown kid, do a background refresh and fail open for the current request (or fail closed for high-sensitivity tenants; state this trade-off explicitly).
Revocation in layers:
- Short TTL (5–15 min): limits exposure to the window even with no active revocation.
- jti blocklist: on revoke, write
revoked:{jti}to Redis with TTL equal to remaining token lifetime. Each service node maintains a local bloom filter fed by pub/sub. A bloom hit falls back to a direct Redis check. False positives cause one extra lookup, never a false denial. - Bulk revocation: store a
not_beforeepoch per subject or tenant. Any token withiat < epochis immediately invalid. This handles "revoke all sessions for this user" without enumerating individual jtis.
Mid-transfer revocation: revoking a principal marks their active sessions REVOKED in Postgres, stops new part URLs from being issued, and aborts the multipart upload at the storage layer. URLs already issued expire within 15 minutes (proxy path: immediate cutoff).
Key rotation sequence: publish new key in JWKS → wait one cache-refresh interval → begin signing with new key → keep old key in JWKS until max token TTL has elapsed → remove old key. Violating the ordering drops live traffic.
4. API Design
# Upload lifecycle
POST /v1/uploads {path, size, sha256, part_size}
-> {upload_id, part_count, expires_at}
POST /v1/uploads/{id}/parts:presign {parts: [{n, sha256}]} -> {urls[]}
PUT <presigned-url> (x-amz-checksum-sha256, Content-Length)
GET /v1/uploads/{id} -> {completed_parts[], missing_parts[]}
POST /v1/uploads/{id}:complete -> 202 VERIFYING -> AVAILABLE
DELETE /v1/uploads/{id} -> abort
# Download
POST /v1/files/{file_id}:download -> {url, size, part_size, part_hashes[]}
GET <url> Range: bytes=<start>-<end> (parallel, per-part)
Resume: client calls GET /uploads/{id} to get the missing-parts list and re-sends only those. No restart from byte zero.
Download resume: clients issue HTTP Range requests per part and validate each range against the per-part hash list returned at download initiation.
5. Integrity Verification
Per-chunk: the client declares a SHA-256 in the presign request; object storage verifies it on write. Mismatch → 400, client retries that part only.
Whole-file, synchronous gate: on complete, the transfer service checks all parts are present, sizes sum correctly, and computes a composite hash (SHA-256 of concatenated part-hashes in order). This is fast and catches missing or swapped parts instantly.
Whole-file, async verification: an async worker streams the assembled object and recomputes the full SHA-256 against the expected_sha256 declared at upload initiation. The file stays in VERIFYING status and is not accessible until this passes. This catches storage-layer corruption and any tampering between write and read.
6. Failure Handling
Idempotent retries: a part is keyed by (upload_id, part_no). Retrying with the same checksum returns success as a no-op. Retrying with a different checksum before complete overwrites the part (last writer wins, tracked in the manifest row). After complete, a conflicting retry returns 409.
Out-of-order parts: parts can arrive and be stored in any order. The complete call assembles them by part number from the manifest, not arrival sequence.
Common mistakes to avoid:
- Validating token signatures via a remote call on every request — kills your 5 ms budget.
- Buffering full chunks in a proxy — 320 GB of RAM at peak.
- Skipping async full-file verification — composite hash alone does not catch storage-layer corruption.
- Key rotation that removes the old key before all tokens signed with it have expired — drops valid live sessions.
- Treating pre-signed URLs as secure tokens — they are bearer credentials; scope them tightly (one part, one checksum, 15-minute expiry, IP/VPC condition in bucket policy).