How to Set File Size Limits and Storage Quotas in SaaS
Set file size limits and storage quotas with server-side checks, reserve-then-commit accounting, and nightly reconciliation. A practical guide to picking the numbers.
Setting file size limits and storage quotas in a custom SaaS product comes down to three decisions: what to cap per file, what to cap per account, and where each check runs. Put the numbers in configuration rather than code, enforce every limit on the server, and keep a running byte count per tenant that a scheduled job reconciles against real storage. The rest is edge cases, and most of them involve deletion.
What is the difference between a file size limit and a storage quota?
A file size limit caps one upload; a storage quota caps everything a tenant holds at any moment. The first is checked per request, the second is an account-level balance that needs tracking and reconciliation.
A tenant is the account or workspace that owns the data. In a multi-tenant system, meaning one deployment serves many customers, every file needs an owner column before you can enforce anything. Get that schema decision right early. Retrofitting tenant ownership onto an existing files table is a migration with real downtime attached.
Start from usage and unit economics, not a competitor's pricing page
Copying a competitor's number is the fastest way to ship a limit that annoys the wrong users. Measure instead. Pull the 95th percentile of file sizes your users already upload, then set the per-file cap at roughly two to three times that figure so ordinary work never touches it.
Unit economics set the quota. Object storage, meaning the S3-style service that holds files outside your database, costs a fraction of a cent per gigabyte per month at most providers. A 10 GB quota on a $50 plan is rarely the line item that hurts. Support time is. Aim for a quota that is roughly 10 to 20 times what your median tenant actually uses, so the limit catches abuse and runaway sync clients rather than normal growth.
Where should file size limits be enforced?
Every limit needs a server-side check, because a browser-only check can be bypassed with a modified request. Client-side checks still help by stopping oversized uploads early, before they consume bandwidth on both ends.
A single check is not enough, because each layer fails differently. Work through them in order:
- Browser pre-check. Reads the file's size property before the upload starts. Saves bandwidth, enforces nothing.
- Request body cap. The API gateway, the proxy that terminates requests before they reach your application, rejects anything over a configured size. Many defaults sit between 1 MB and 10 MB, so raise the limit deliberately and note it in your runbook.
- Application validation. The authoritative check. Runs before a single byte is written.
- Quota accounting. Updates the tenant's byte count in the same transaction that records the file.
- Reconciliation. A job that lists real objects in storage and compares them to your accounting table, typically nightly.
| Limit | Enforced at | Typical starting value | Failure it prevents |
|---|---|---|---|
| Max single file | Application, before write | 25 MB documents, 250 MB media | One upload exhausting a worker's memory |
| Tenant storage quota | Accounting table, checked on upload | 10 GB on a mid-tier plan | Unbounded cost growth per account |
| Uploads per hour | Rate limiter | 60 per tenant | Scripted abuse, looping sync clients |
| Allowed file types | Application, by detected content type | An allowlist | Executables and mislabelled files |
Which limits should a new SaaS product ship with?
Ship three from the start: a per-file cap, a per-tenant storage quota, and an upload rate limit. Make all three configurable per plan so pricing changes do not require a deployment.
Configurable means a database row or a feature flag, not a constant in the upload handler. The day a sales team promises a 100 GB allowance to one customer, someone should change a value and log the change, not open a pull request.
How do you enforce a storage quota without breaking uploads?
Reserve the expected bytes before the upload starts, then commit the actual size once the file lands. Reserving stops two simultaneous uploads from both passing a check that each would have failed alone.
This is the reserve-then-commit pattern, and it matters because uploads are concurrent by nature. A user drops in a folder of 40 files and the browser fires several requests at once. Without a reservation, all of them read the same remaining-bytes figure and all of them pass. With one, the second request sees the first request's hold and gets rejected honestly.
The flow, in order:
- The client asks for an upload slot, sending file name, byte size, and content type.
- The server checks size against the per-file cap, type against the allowlist, and quota against committed usage plus active reservations.
- The server writes a reservation row and returns a pre-signed URL, a time-limited link that lets the browser upload straight to object storage.
- The client uploads directly to storage, so large files never pass through your application servers.
- The client confirms, the server reads the object's real size, converts the reservation into a committed record, and adds the bytes to the tenant's usage.
- A sweeper expires reservations older than roughly two hours, freeing bytes held by abandoned uploads.
Every step in that chain must be idempotent, meaning repeating the same request produces the same result rather than double counting. Networks retry. Browsers retry. A confirmation endpoint that adds bytes twice will drift your quota within a week.
What happens when a tenant hits the limit?
New uploads stop and existing files stay readable, which protects the account without holding its data hostage. Most products warn at roughly 80% of the quota and block at 100%, with a short grace period for active accounts.
Blocking reads is the mistake to avoid. An account that cannot download its own invoices because it went over quota generates a support ticket and a refund conversation, and it does not recover any storage. Warn by email and in-app at 80%, block writes at 100%, and give a 7 to 14 day grace window on paid plans before anything else happens.
Never delete files to get a tenant under quota. That decision belongs to the customer, and the liability sits with you.
Deletion is where quotas quietly break
Soft delete, where a row is marked deleted but the bytes remain, means usage does not drop until a purge job runs. Object storage versioning keeps every overwrite as a separate billable copy. Multipart uploads, which send one large file as many chunks, leave incomplete parts behind when a client disconnects, and those parts bill normally.
Handle each one deliberately. Purge soft-deleted files on a fixed schedule, cap the number of retained versions per object, and configure a lifecycle rule that aborts incomplete multipart uploads after a day or two. Then let the nightly reconciliation job do its work. Drift is usually small, a fraction of a percent of files in a healthy system, but it compounds silently in one direction.
How long does this take to build?
A first working version, covering schema, upload path, quota checks, an admin override, and reconciliation, typically takes two to four weeks for a small team. Overage billing integration adds another one to two weeks.
If the storage layer is part of a wider custom SaaS build, put the quota model in the same design pass as billing. Limits, plans, and invoices are one system. Splitting them across two projects is how a product ends up with three quota implementations and no single answer to how many bytes a customer is using.
Frequently asked questions
How do you enforce a storage quota per tenant?
Track committed bytes per tenant in a database column and check it before every upload, alongside a reservation for uploads that are in flight. Confirm the real object size after the upload lands and reconcile the totals against a listing of actual storage on a schedule, so accounting errors do not accumulate.
What is a reasonable file size limit for a SaaS upload?
There is no universal number, but 25 MB for documents and 250 MB for media covers most business applications. If you have existing usage data, set the cap at roughly two to three times your 95th percentile file size so normal work never touches the limit.
Should storage quotas be soft limits or hard limits?
Use both. A soft limit warns the tenant at roughly 80% of the quota while uploads still succeed, and a hard limit blocks new writes at 100% while leaving existing files readable. Blocking downloads as well creates support load without freeing any storage.
Why do concurrent uploads break quota checks?
Several uploads firing at once each read the same remaining-bytes figure, so they all pass a check that would have failed if they had run in sequence. Reserving bytes before the upload starts closes that gap, and a sweeper job expires reservations abandoned by dropped connections.