Lifecycle and security · Engineering
Per-database quotas and writer backpressure
How data, index, history, and sidecar quotas are enforced at the writer, and what happens at the hard limit.
A shared database instance has a failure mode that is easy to miss: one application fills the disk and every other application stops working. Per-database quotas are a simple defense.
NonoDB supports independent storage limits per database. They protect the shared instance, not just the individual application.
The resources
| Resource | Covers |
|---|---|
data_bytes |
Stored documents and TTL metadata |
index_bytes |
Secondary and vector index storage |
history_bytes |
Document revision history |
sidecar_bytes |
Search and vector sidecar files |
Usage is the reported stored size, not the JSON payload size. A limit applies only to its own resource; setting a data limit does not restrict index creation.
Search and vector sidecars are counted separately because they are immutable files. WAL and PITR snapshots have their own retention limits and are not part of the quota.
Configuration precedence
A database uses:
- limits saved with
set_quota; - environment defaults for limits that were never saved.
Environment defaults:
| Variable | Default |
|---|---|
NONODB_QUOTA_DATA_BYTES |
unlimited |
NONODB_QUOTA_INDEX_BYTES |
unlimited |
NONODB_QUOTA_HISTORY_BYTES |
unlimited |
NONODB_QUOTA_SIDECAR_BYTES |
unlimited |
NONODB_QUOTA_SOFT_PERCENT |
80 |
Sizes accept bytes or suffixes such as 512MiB, 10GiB, and 2GB. A saved configuration survives restarts. Setting a limit to null or 0 clears it.
Reading usage
get_quota returns limits, usage, status (ok, warning, exceeded), soft-limit percentage, and warnings:
{ "op": "get_quota"}The same quota object appears in database_stats. The CLI exposes it with nonodb-cli --db app1 quota.
Changing limits
set_quota replaces the whole saved configuration:
{ "op": "set_quota", "limits": { "data_bytes": 21474836480, "index_bytes": 5368709120, "history_bytes": 2147483648, "sidecar_bytes": 5368709120 }}Omitted fields, null, and 0 mean unlimited. The operation requires a database administrator scope.
The CLI quota set changes only named limits and keeps the others; quota reset clears the saved configuration.
Enforcement at the writer
When a growing write would cross a hard limit, the write fails with HTTP 507 and error code quota_exceeded. The failed write is not partially applied.
That includes inserts, updates, index builds, text/fuzzy/vector index creation, and SQL or aggregation writes that add storage.
Space-releasing operations remain allowed after a quota is reached: deletes, collection and index drops, history pruning, TTL expiry, and similar operations. An operator can recover without raising the limit.
The check is conservative for grouped writes. A request may be rejected when the limit is already exhausted even if that particular request would not have added bytes to the exhausted resource. Retry after freeing space.
Soft warnings
A resource starts warning at the soft percentage (default 80) and is exceeded at the hard limit. Warnings appear in get_quota, database_stats, and the CLI, and are logged. Rejections are logged as errors.
Soft warnings are the time to act: add retention, prune history, or raise the limit before the writer starts returning 507.
Why writer-level enforcement
Enforcing at the writer gives a clear failure: the write either commits or returns an error. It does not leave a half-written index or a document whose sidecar failed later.
The trade-off is that a write can fail for a reason unrelated to its own content. The quota is a database-level budget, not a per-collection budget.
Operational checklist
- Set quotas before multiple applications share an instance.
- Use separate limits for data, indexes, history, and sidecars.
- Alert on
warning, not onlyexceeded. - Keep a recovery path: deletes, drops, and retention still work.
- Test a 507 response in staging so clients handle it.
- Remember that compaction can change actual file size but not the reported logical usage.
- Do not use quotas as a substitute for disk monitoring; the host can still fill from other data.
What quotas do not do
- They do not reserve disk space for other databases.
- They do not limit CPU, memory, or request rate.
- They do not cap WAL/PITR retention.
- They do not prevent a single large document from being written; document size limits apply separately.
- They do not replace per-database auth.
The quota guide documents the exact API, CLI, environment defaults, and error behavior.