Scrivio Interview library
DesignIntermediate7 min read · updated 12 November 2026

Users need to upload video files of up to 5 GB. Design the upload flow for a Spring Boot service running behind a load balancer with 30-second request timeouts.

We keep the 5 GB bodies away from our application entirely: the service issues pre-signed URLs and the client uploads directly to object storage, using the storage service's multipart or resumable upload so each part is small and can be retried. The application only records metadata, confirms completion through a callback or a storage event, and then scans and processes the file asynchronously before making it visible. Per-user size and rate limits, URL expiry and automatic cleanup of unfinished uploads close the design.

Why this question is asked

Large uploads break naive designs in predictable ways. A 5 GB file over a 50 Mbps home connection takes about 14 minutes, while our load balancer cuts requests at 30 seconds. Even without that limit, streaming gigabytes through application instances ties up threads and network capacity, and any network blip forces the user to start again. Interviewers ask this question to see whether we recognise that the right answer is to move the heavy work out of the request path. In this answer, we will see why proxying fails, how pre-signed URLs and multipart uploads work, walk through the full flow, and then add validation, scanning, limits and cleanup.

1Why the Simple Design Cannot Work

The simple design is a Spring endpoint that accepts the file and writes it to storage. Let us put numbers on it. At 50 Mbps, 5 GB is 40,000 megabits, so the upload takes 800 seconds, more than 26 times the 30-second timeout. We could raise the timeout, but the load balancer is usually shared and its limits exist for good reasons. Even if we could, each upload would hold a connection and a server thread for 13 minutes, double the bandwidth through our instances (in from the client, out to storage), and a deploy or instance restart in the middle would throw away the whole upload.

So the problem is not the timeout itself. The problem is that our application is in the data path at all. Object storage services such as Amazon S3, Google Cloud Storage and Azure Blob Storage are built to accept huge uploads from many clients at once; our job is to authorise and track them.

2A Quick Recap of Pre-signed URLs and Multipart Uploads

A pre-signed URL is a normal HTTPS URL to the storage service with a signature in its query string. Our service creates it with its own credentials, for one specific object key, one HTTP method and a short expiry, say 15 minutes. Whoever holds the URL can perform exactly that operation and nothing else, without having any storage credentials. The client sends its PUT directly to storage, and our load balancer never sees the bytes.

A multipart upload splits one object into parts that are uploaded independently and then joined by the storage service. In S3, we start the upload and get an uploadId, upload parts (each at least 5 MiB except the last, up to 10,000 parts), and finally complete the upload with the list of part numbers and their ETags, the checksums storage returned for each part. With 100 MB parts, a 5 GB file is 50 parts. If part 37 fails, the client retries part 37 only. Google Cloud Storage offers resumable uploads with a similar effect, and Azure uses block blobs.

3The Upload Flow Step by Step

Here is the whole flow. Every request that touches our service is small and finishes in milliseconds, so the 30-second limit no longer matters.

Step throughDirect-to-storage upload of a 5 GB file
ClientUpload APIObject storageWorker
POST /uploads {name, size, type}
check quota, create record PENDING
start multipart upload
uploadId + pre-signed part URLs
PUT part 1..50 directly (retry failed parts)
POST /uploads/{id}/complete {ETags}
complete multipart upload
object-created event
verify size, scan, transcode
mark READY (or REJECTED)

10 messages in order. Play them, or step through them one at a time.

Notice that the client gets the part URLs from us, but sends bytes only to storage. The URLs can be issued in batches, for example 10 at a time, so an abandoned upload does not hold 50 valid URLs. The complete call goes through our API so we can check that the uploadId belongs to this user and that the declared size matches; alternatively the client completes the upload itself and we rely only on the storage event.

4Recording Metadata and Confirming Completion

The service owns the upload record: who uploads, the generated object key (never the user's filename), the declared size and type, and a status such as PENDING, UPLOADED, SCANNING, READY or REJECTED. The key looks like uploads/2026/11/7f3c9a.../original so it cannot collide or be guessed.

We should not trust the client's complete call alone, because a client can call it and never upload, or upload a different size than it declared. So completion is confirmed from the storage side. Most services emit an event when an object is created (S3 event notifications to a queue, for example), and a worker consumes it, reads the object's real size, compares it with the record, and moves the record forward. That worker is also where processing starts, such as generating thumbnails or transcoding video, all asynchronous, so the user sees "processing" in the UI rather than a spinning request.

Java
@PostMapping("/uploads")
UploadTicket start(@AuthenticationPrincipal User user, @Valid @RequestBody UploadRequest req) {
limits.check(user, req.size()); // 413 or 429 if over quota
String key = "uploads/" + UUID.randomUUID() + "/original";
String uploadId = storage.startMultipart(key, req.contentType());
uploads.save(new Upload(user.id(), key, uploadId, req.size(), Status.PENDING));
return new UploadTicket(uploadId, storage.presignParts(key, uploadId, 1, 10, Duration.ofMinutes(15)));
}

This endpoint finishes in a few milliseconds. The expensive parts of the system, the upload itself and the processing, both happen outside the request.

5Scanning and Validating Before the File Is Visible

A file that has been uploaded is not yet a file we serve. It lands in a quarantine area, a bucket or prefix that nothing else can read. The worker checks the real content type from the bytes (a video container starts with known signatures), checks that it is within the allowed duration and size, runs malware scanning, and only then copies or moves the object to the location that downloads and players use, setting the record to READY. Anything that fails becomes REJECTED and is deleted after a short period. The reason for this order is that the moment a file is visible, others may download it; validating afterwards would be too late.

6Limits, Expiry and Cleanup

Direct uploads move bandwidth off our servers, but they do not remove the need for limits. We enforce a maximum size per file (5 GB) in the start call and, where the storage service supports it, in the signed request itself, so a client cannot upload more than it declared. We add a per-user quota, for example 50 GB total and 20 uploads per day, and rate limit the start endpoint so one account cannot create thousands of pending uploads.

Unfinished uploads must expire, because incomplete multipart parts are stored and billed even though no object exists yet. Pre-signed URLs expire on their own after 15 minutes. A storage lifecycle rule aborts incomplete multipart uploads after, say, 24 hours, and a scheduled job marks PENDING records older than that as EXPIRED. Without these two, a service that sees many abandoned uploads can quietly pay for terabytes of invisible parts.

What protects what
ControlWhereProtects against
Max size per filestart call + signed requesta 50 GB upload declared as 5 GB
Per-user quota and rate limitUpload APIone account filling storage
URL expiry (15 min)pre-signed URLleaked URLs reused later
Abort incomplete uploads (24 h)storage lifecycle rulebilled, invisible parts
Quarantine and scanworkermalware or wrong file types served

7Follow-up questions

Why not just raise the load balancer timeout to 30 minutes?

Because the timeout is only the first symptom. Proxying 5 GB through our instances still doubles bandwidth, holds a thread or connection for many minutes, breaks on every deploy and gives the user no way to resume. Direct uploads with parts solve all of these at once and keep the load balancer's limits for the rest of the system.

How does the client resume after closing the laptop?

The upload record keeps the uploadId. When the client returns, it asks our API which parts storage already has (S3 can list the uploaded parts of a multipart upload), receives fresh pre-signed URLs for the missing parts only, uploads them, and completes. As long as the cleanup rule has not aborted the upload yet, nothing already sent is lost.

How do you keep a pre-signed URL from being abused?

Sign it for one key, one method and a short expiry, issue it only after authorisation and quota checks, and where the service allows, include conditions such as content length. The key is generated by us, so the URL cannot overwrite another user's file, and the quarantine step means that even a valid but malicious upload never reaches other users unscanned.

8Conclusion

In this answer, we designed a 5 GB upload flow that never sends file bytes through our Spring Boot service. The service authorises the upload, creates a metadata record and hands out pre-signed URLs for the parts of a multipart or resumable upload; the client uploads directly to object storage and retries failed parts. Completion is confirmed by a storage event, a worker validates and scans the file in quarantine and processes it asynchronously, and only then is it visible. Size limits, per-user quotas, URL expiry and automatic aborting of unfinished uploads keep the system safe and its costs under control.

What to say in the interviewAbout 90 seconds aloud

Open with

With a 30-second timeout, a 5 GB upload can never go through the application: at 50 Mbps it takes about 13 minutes, and proxying it would also double our bandwidth and break on every deploy.

Then, if they want more

So I take the application out of the data path. The client first calls our API with the file's size and type. The service checks the user's quota, creates an upload record with a generated object key, starts a multipart upload in object storage, and returns short-lived pre-signed URLs for the parts, say 100 MB each, issued in batches.

The client uploads the parts directly to storage and retries any part that fails, so a network drop costs one part, not the whole file. Then it calls complete, and we verify ownership and finish the multipart upload.

I would not trust the client alone for completion: a storage event triggers a worker that checks the real size and type, scans the file in a quarantine location, and starts transcoding asynchronously, and only then marks it ready and visible.

Around that I add limits: maximum size in the start call and the signature, per-user quotas and rate limits, URL expiry of about 15 minutes, a lifecycle rule that aborts incomplete uploads after a day, and a job that expires pending records.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Users need to upload video files of up to 5 GB. Design the upload flow for a Spring Boot...": https://scrivio-interview-library.netlify.app/spring-boot/web-other/3fd5f7781f/