Production / Limits and defaults
Limits and defaults
Every bound and default of TinyStore in one place, by engine. A call past a
bound fails with a limit or invalid error that names the bound, and
changes nothing. Each engine's guide repeats its own numbers in a table
beside the calls they bound, and the chapters of the book link here instead
of repeating them.
The store
| What | Limit or default |
|---|---|
| durability | 'full' for kv, jobs, sql and blobs; 'os' for records and metrics |
| memory budget | none unless set; 1 GiB for tinystore serve --listen |
| a call waiting for memory | 10 seconds, then limit |
| free disk the store keeps | 1 GiB, keepFree |
| a time in the future | 10 minutes ahead of the store's clock |
| a sidecar with no clients | exits after 30 seconds |
command line connections a store opened with cli serves | 4 at once; the next is told GOAWAY limit |
a cli store's close | waits 2 seconds for the command line's calls, then cuts them off |
| a name of a bucket, queue, stream, database, index, config | [a-z0-9][a-z0-9_-]{0,63} |
SQL
| What | Limit or default |
|---|---|
| a transaction | 5 seconds |
rows all or columns holds | 64 MiB of values, inside a transaction too |
one each read | 5 seconds of one snapshot, then limit naming list |
an each ordered by a unique key | a new snapshot every 5 seconds, after its last row |
rows each holds | a few parts of about 1 MiB |
| writes in one shared commit | 1,024, or 8 MiB |
| values of one statement | 32,766: an insert or upsert list's rows times columns |
| readers | one per processor, 4 to 16, idle ones close after a minute |
| a mirror's list, and its scope | 100,000 rows each |
| statements compiled per connection | 128 |
KV
| What | Limit or default |
|---|---|
| a key, with its owners | 1 KiB |
| a value | 1 MiB |
a page of list | 1,000 keys |
| a quota | one to eight windows |
| rate limits and counters in memory | 100,000 keys per name, written every second |
| an idle key's renewal | once a thirtieth of its span has passed |
a once run's answer, kept | 1 day unless keep says |
Jobs
| What | Limit or default |
|---|---|
attempts | 10 |
backoff | from 1 s, doubling, up to 1 h, ±10 % at random |
timeout | 1 minute per run |
| a lease | 30 seconds, renewed every 15 while a run lasts |
keep of failed jobs | 7 days |
| waiting jobs | 10,000,000 per queue, maxWaiting |
| an id, a group | 1 to 1,024 bytes |
| a value, a step's answer | 1 MiB of JSON |
| progress | 4 KiB of JSON |
| a page | 1,000 jobs or 4 MiB |
ahead | exact to 10,000, then 10,000 and aheadAtLeast |
Blobs
| What | Limit or default |
|---|---|
| a file | none, unless maxFileSize |
| a path with its folders | 1 KiB and 16 segments |
| a content type | 256 bytes |
meta | 2 KiB in all |
| a page | 1,000 files |
| a file kept as a row | up to 16 KiB; larger ones are files of their own |
| a set's files together | none, unless maxSize, which the set keeps |
| files one write evicts | 10,000 |
| a use a read records | once an hour, or a thirtieth of idle |
Search
| What | Limit or default |
|---|---|
| a document | 1 MiB |
setMany | 1,000 documents; 16 MiB of JSON |
| a search's text | 1 KiB, its first 32 words |
| a vector | 4,096 dimensions |
limit + offset | 1,000; limit is 10; a total exact to 10,000 |
| a field's weight | above 0, at most 1,000 |
| a filter | 8 conditions, 1,000 values; a statement's rows, 100,000 |
vectorWeight | 0.5 |
| a table's index | the rows of one search's hits, 64 MiB together, as one all |
store.search | 1 to 32 indexes; a group's limit + offset 1,000, limit 10; boost above 0, default 1 |
Channels and locks
| What | Limit or default |
|---|---|
| a message | 1 MiB |
| a branch's log | its newest 1,024 messages or 4 MiB |
| every channel's messages | 64 MiB of the store's memory |
| a store's subscriptions | 10,000 |
| a connection's pending output | 8 MiB |
a lock's wait | 10 seconds |
a lock's ttl, a lease | 10 seconds in an SDK, 30 in tinystore lock hold, 1 second to 1 hour |
a semaphore's limit | 1 to 1,000 |
maxHold | none |
Records and metrics
| What | Limit or default |
|---|---|
a stream's keep | 14 days |
| a logger's buffer | 1,024 lines, written every second |
| a page of events | 1,000, at most 10,000 |
a list in a records where | 1 to 1,000 values, each at most 4 KiB |
a top or a largest | 10 answers, at most 1,000 |
a name's keep in metrics | 30 days |
| instruments' writes | 15 seconds, flush, a read, and close |
| sets of labels per instrument | 2,000 between two sends, then __overflow |
| series in a store | 100,000 |
| buckets of an aggregate | 100,000, past it a page at a time |
| series of a metrics query | 1,000, past it a page at a time |
earlier windows of a compare | 1,000 |
Nodes
| What | Limit or default |
|---|---|
| a link that has not shown its token | closed after 10 seconds, or past 64 KiB before it |
| links that have not shown their tokens yet | 64 at once |
Over the wire
Bun, Node, Python and Go send each call to the core as one request, and get one answer back. The same holds with the core in your own process, in a private child, a sidecar or a remote server.
A request or an answer can be up to 64 MiB. When one is larger than 2 MiB,
the frame size the SDK agrees with the core when it connects, the SDK and
the core split it into frames and join them on the other side. You don't
see this: the engine still gets one request, so a setMany, an append
of a list, a batch or a transaction still commits once or not at all.
Past 64 MiB, the SDK refuses the request before it sends anything, so it changes nothing. The error names the call:
search.setMany: a request of 70074001 bytes, past the 67108864 a message holdsAn answer past 64 MiB fails with the limit answer bytes for a read. For
a write, it fails outcome_unknown, since the write already ran.
The 64 MiB counts the requests one connection sends in pieces at once, too. Each SDK waits for an earlier large request to finish before it sends one that would pass it, so you only meet the bound with one request.
The engines' own bounds still apply and usually come first: a setMany is
at most 16 MiB of JSON, and an append at most 4 MiB of events.
Against a server of 0.13 or older, which can't join frames, every request
and answer is one frame of at most 2 MiB, and the error says a body holds.
A Rust program calls the engines directly, so it never meets these bounds.
Bounds by name
Each bound that one call meets has a name. When a call passes it, the limit
error (LimitError in Bun and Python, ErrLimit in Go, ErrorKind::Limit
in Rust) carries three facts:
limit, the bound's name, for exampleset_many documentswanted, what the call would have taken of it, for example 1001bound, the most it takes, for example 1000
They are fields of the error in Bun, Python and Go, and error.fact("limit")
and its like in Rust.
Each SDK exports the same bounds, so a program can size its batches before it calls, and can tell which bound an error met without reading its message:
import { limits } from '@tinyshed/tinystore'
const courses = store.index<Course>('courses', { fields: { name: 1 } })
const most = limits.setManyDocuments.bound
for (let at = 0; at < catalogue.length; at += most) {
await courses.setMany(catalogue.slice(at, at + most))
}from tinystore import bounds
courses = store.index("courses", Course, fields={"name": 1})
most = bounds.SET_MANY_DOCUMENTS.bound
for at in range(0, len(catalogue), most):
await courses.set_many(catalogue[at : at + most])The bounds live in limits in Bun and Node, in tinystore.bounds in
Python, in the limits package in Go and in tinystore::limits in Rust.
Python's tinystore.limits is a different module: rate limits and quotas.
Each constant has the name below in its language's case:
limits.setManyDocuments, bounds.SET_MANY_DOCUMENTS,
limits.SetManyDocuments and limits::SET_MANY_DOCUMENTS.
| Constant | The error's limit | Bound | What it bounds |
|---|---|---|---|
VALUE_BYTES | value bytes | 1 MiB | a bucket's value |
SETTING_BYTES | setting bytes | 16 KiB | a live setting's change, as JSON |
CONFIG_BYTES | config bytes | 256 KiB | every change a config keeps |
LOCK_WAITERS | lock waiters | 10,000 | callers waiting for one lock or semaphore |
SUBSCRIPTIONS | subscriptions | 10,000 | subscriptions to the store's channels |
JOB_BYTES | job bytes | 1 MiB | a job's payload, result or step's answer, as JSON |
PROGRESS_BYTES | progress bytes | 4 KiB | a run's progress, as JSON |
ROWS_BYTES | bytes of a call's rows | 64 MiB | the values one call reads from a database |
MIRROR_ROWS | mirror rows | 100,000 | the rows of a mirror's list, and the rows in its scope |
EVENT_BYTES | event bytes | 256 KiB | one event |
APPEND_BYTES | append bytes | 4 MiB | the events of one append |
AGGREGATE_ROWS | aggregate rows | 10,000 | the rows of one aggregate of events |
COUNT_BYTES | count bytes | 64 MiB | the different values one top or distinct holds |
SESSIONS | sessions | 10,000 | the sessions one sessions call keeps, open ones included |
SESSION_BYTES | session bytes | 64 MiB | the events and by values one sessions call keeps |
WHERE_VALUE_BYTES | where value bytes | 4 KiB | a value that a statement of a records where gives, as JSON |
SUM_RANGE | sum range | 128 | the bits a sum of integers in an aggregate's stats is held in |
INGEST_SAMPLES | ingest samples | 100,000 | the samples of one ingest, in one write |
INGEST_BYTES | ingest bytes | 32 MiB | the samples of one ingest with their labels |
REPLACE_SAMPLES | replace samples | 10,000 | the samples of one gauge's replace |
REPLACE_BYTES | replace bytes | 4 MiB | the samples of one replace with the series' labels |
TEXT_SAMPLES | text samples | 100,000 | the samples of one exporter's text |
TEXT_BYTES | text bytes | 32 MiB | one exporter's text |
QUERY_SERIES | series | 1,000 | the series one metrics query finds |
QUERY_BYTES | bytes read | 16 MiB | what one metrics query reads from the file |
QUERY_SAMPLES | samples decoded | 1,048,576 | the samples one metrics query decodes |
QUERY_ANSWER | answer | 100,000 | the samples or buckets one metrics query answers |
SET_MANY_DOCUMENTS | set_many documents | 1,000 | the documents of one setMany |
SET_MANY_BYTES | set_many bytes | 16 MiB | the documents of one setMany as JSON |
DOCUMENT_BYTES | document bytes | 1 MiB | one document as JSON, or a table's row as its index reads it |
SEARCH_HITS | search hits | 1,000 | offset and limit of one search together |
SEARCH_TEXT | search text | 1 KiB | a search's text |
FILTER_CONDITIONS | filter conditions | 8 | the conditions of one search's filter |
FILTER_VALUES | filter values | 1,000 | the values in the lists of one search's conditions |
FILTER_ROWS | filter rows | 100,000 | the rows a statement of a table's index's where gives |
FILTER_TEXT | filter text | 256 bytes | a text that a filter keeps or asks for |
VECTOR_DIMENSIONS | vector dimensions | 4,096 | a vector |
REQUEST_BYTES | request bytes | 64 MiB | one request from an SDK; 2 MiB to a server of 0.13 |
ANSWER_BYTES | answer bytes | 64 MiB | one answer to an SDK; 2 MiB from a server of 0.13 |
| A bound that the store's options set is named the same way, but it has no | |||
constant: store memory and store memory, now for the memory budget, | |||
series in a store for maxSeries, waiting jobs for a queue's | |||
maxWaiting, file bytes for a set of files' maxFileSize, and set bytes | |||
for its maxSize. The error's bound gives the number that this store uses. |
testdata/wire/limits.json holds the table, and each SDK's tests check
their constants against it.
See also
- One budget of memory: how bounds and the budget fit together.
- What TinyStore promises: the contracts behind the bounds.