Limits

Limits of databases and budget groups, the default limits, how they bind across processes, and what a client sees at a limit.

A process serves many databases. Limits bound what each database, and each budget group of databases, may take of the deployment, so that one tenant's load delays but never starves the others. This page explains the records, how to set them and what a client sees at a limit.

Resources

A limit names a resource and an amount. Each resource is charged in one of three ways:

ResourceUnitCharged
connectionsopen sessionsWhile open
in_flightrequests being servedWhile served
pending_repliessubmits awaiting answersWhile waiting
queued_workqueue entriesWhile queued
memorybytesHeld while the allocation lives (buffers, resident documents)
retainedbytes kept in the storesHeld while retained
appendbytes written per secondPer second
cpuwork units per secondPer second
scannedrecords read per secondPer second
transferbytes sent and received per secondPer second
presencepresence deliveries per secondPer second

A rate limit is an allowance per one-second window. A request larger than what is left is still admitted when its database and group owe nothing, and what it takes beyond the window is paid by the following windows, so a large request is slowed down, never refused for good.

Records

RecordApplies to
A database'sThat database
A budget group'sEvery database of the group, together
The deployment defaultEvery database and group without a record of its own

Everything is admitted against both the database's limits and its group's, so more databases in one group do not escape the group's limit. A record names the resources it limits; one it does not name is unlimited. A record stands in place of the default as a whole. A new deployment has no default record, so a database or group without a record is unlimited: a deployment shared by tenants should set one.

A database's budget group is chosen when it is created, and is fixed.

Setting limits

Limits are set through the administration API, by a superuser; a holder of databases.read may read them. There is no operator command for them.

curl -u admin:"$PASSWORD" "https://mimic.example.com/v1/admin/databases/$DB/limits"
{
  "limits": { "connections": 2000 },
  "access_mode": "read_write",
  "revision": 182,
  "effective": { "connections": 2000 }
}
curl -u admin:"$PASSWORD" -X PUT -H 'Content-Type: application/json' \
  -d '{"connections": 2000, "transfer": 10000000}' \
  "https://mimic.example.com/v1/admin/databases/$DB/limits?revision=182"

A PUT replaces the record whole. effective is what applies: the record, else the default, else nothing. ?revision= makes the change only while the record is still at the revision you read (?revision=0: only while there is none), and refuses it revision_mismatch otherwise, so an automated writer never overwrites a change it did not see. DELETE removes the record. Budget groups' records are at /v1/admin/budget-groups/{group}/limits, the default at /v1/admin/default-limits.

A database's record and the default may also name migration_rate: how many documents per second its schema migrations migrate in the background (20 when not named, 0 to stop them), and the limits of its triggers (max_endpoints, max_triggers and others). These are not resources and are not charged.

How limits apply across processes

  • Rate limits (append, cpu, scanned, transfer, presence) bind all the processes together: each admits its share of the allowance, leased from the home store every second.
  • Concurrency and memory limits (connections, in_flight, pending_replies, queued_work, memory, retained) bind in each process: a database limited to L connections can hold up to n × L across n processes. Size them for the number of processes.
  • A document's work is charged where it runs: at the process holding its partition.
  • Changes reach every process as its view of access data does, within access_max_staleness_ms (10 seconds by default).
  • Lowering a limit refuses new work above it and takes nothing back: no write, open session or retained byte is discarded. A database over its retained limit refuses new records, but its documents are still checkpointed.
  • Nothing before authorization. A request is charged to its database only once its credential is verified for it. Work before that is bounded per process and per source address.

What a client sees at a limit

WhereWhat happens
An HTTP requestStatus 429, code resource_exhausted. The SDK retries it with backoff
A session's writeAnswered resource_exhausted; the client keeps the edit and sends it again with backoff
A new sessionRefused resource_exhausted; the client reopens with backoff
Bytes sent and receivedDelayed, never refused: sessions and answers wait for the transfer allowance
PresenceDelayed, never refused: deliveries wait for the presence allowance

mimic_admission_refusals_by_resource_total, by resource, counts refusals (see Observability).

Registry bounds

Some bounds are constants of the release, not limits: a database holds at most 1,000 collections not removed, a schema is at most 3 MiB stored, and a database's registry (collections, schema versions, migrations, endpoints and triggers) at most 64 MiB. A request past one is refused, naming the size and the bound.

Stopping writes without removing a database

To make a database read-only or block it, set its access mode rather than a limit:

curl -u admin:"$PASSWORD" -X PUT -H 'Content-Type: application/json' \
  -d '{"mode": "read_only"}' \
  "https://mimic.example.com/v1/admin/databases/$DB/access-mode"

See Administration.

Isolation

Limits divide what shared processes give each database; they are not a hardware boundary. A tenant that needs its own storage and write throughput gets a store of its own; one that needs its own compute gets a deployment of its own. The earlier server's isolation classes do not exist here: a database's creation refuses class and shard.