Every
413 is gRPC RESOURCE_EXHAUSTED. The OTLP spec says a client does not send it again: that batch is lost. A 429 and a 503 are sent again.
Writes at a time
At most 16 writes (OTLP exports over HTTP or gRPC,POST /v1/scores) read, decode and write at once. At most 64 more wait. The next gets 429 (BUSY).
A waiting write has not read its body: its bytes wait in the socket, not in the server. A write keeps its place until its work on the store ends, also when its client goes away. A slow client holds its place while its body arrives, until --body-timeout ends it. Deletes and purges take no place.
With keys, the server checks the key and its right first: before the write takes a place, and before it reads the body. A gRPC body that is not protobuf, sent with no key, gets UNAUTHENTICATED, not a decode error.
How a refused body is read over HTTP
How a refused body is read over HTTP
Over HTTP the
429 comes at once. The server then reads the refused body to its end and drops it, with no place and no decode: at most --max-body-bytes, within --body-timeout. So a client that sends its whole body before it reads the answer gets the 429, not a reset.A body that says it is longer than --max-body-bytes, or a request with Expect: 100-continue, is not read. gRPC needs no such read: HTTP/2 ends the one stream (tests/busy.rs). Before this rule, the launch proof with 128 clients got 2,585 answers 429 and 797 exports with no answer.The body limit
64 MiB is the default that the OTLP spec recommends for a server and a client. An SDK’s batch processor sends up to 512 spans in one export (OTEL_BSP_MAX_EXPORT_BATCH_SIZE).
512 model calls of 50 KB are 26.0 MB as protobuf and 26.6 MB as JSON (tests/sdk_batch.rs). gRPC has the same limit.
For a larger batch, raise --max-body-bytes, or make the SDK send fewer spans per export. Over HTTP the server still reads the rest of a body over the limit, so the client gets the 413. It reads at most 64 MiB more (or --max-body-bytes, if larger), within --body-timeout. A longer body, or Expect: 100-continue, gets the 413 at once and the connection closes.
Spans and mapped bytes
The mapping puts a copy of the resource’s attributes, and the scope’s name and version, into every span. A request of 30 KB with 100 spans and one resource attribute of 8 KiB became about 800 KiB of spans. So the server measures each request after the decode and before any copy. It counts the spans, and the bytes as protobuf, where each span counts with its resource and scope. Before D341 the default was 4 x a body limit of 16 MiB (64 MiB). Now it is 2 x the body limit: an ordinary batch maps to about its own size. 4 x 64 MiB would let 16 small requests become 4 GiB of spans.import measures each OTLP line the same way, with a quarter of --memory-mb as the byte cap and no span cap.
The decode budget
The server counts the memory of a decode from the bytes, before it decodes. A request that alone needs more than--ingest-memory-mb gets 413 DECODE_TOO_LARGE. The others take their cost from the budget and wait, with their place, until it is free.
Score writes count 1 KiB per object. An import line has a quarter of --memory-mb.
Why: an empty protobuf message is 2 bytes on the wire and 32 to 264 bytes in memory. One body of 16 MiB with 8,388,592 empty spans took the server to 2.27 GB before this rule. Now it is refused at a peak of 35 MB, and 16 of them at once at 297 MB (F78, results/anu84-hardening/decode-budget.json).
How much of the default budget a JSON body takes, as a factor of its bytes (results/anu87-sdk-batch/budget-alloc.txt, F78):
The count is an estimate of the decoder’s memory, not a measure.
tests/budget_alloc.rs checks that no real decode of the tested bodies is above its count; the real decode takes 1.1 to 2.6 times the bytes.
How a body is counted
How a body is counted
Protobuf: every message is counted from its bytes, by the schema and with no allocation. That covers spans, resources, scopes, attributes, values in lists, events, links and entity ids; a text is never read as a message. Each message in a list costs twice its Rust size, and the first of each list 4 times (a
Vec of one item has room for 4; D276). The body’s bytes count once more. In its worst shapes the real protobuf decode comes to 0.96 to 0.99 of its count.JSON (D272, D275): 64 bytes for each value and each key, plus the bytes of each text. These count again for every OTLP AnyValue around them: serde reads an AnyValue through a flatten field, which copies the object once more for each AnyValue it is in.Each object costs what it becomes:The spans of an OTLP/JSON body are counted before the decode, as for protobuf. An array directly in an array is a
400 before the decode: serde reads a struct also from an array of its fields, which no OTLP encoder writes. Before that rule, a 2 MB body with 30 nested arrayValues was counted at 4 MB and decoded to about 1 GB.Lists
One list of a request has at most--max-list-items items (D271), counted before the decode.
The spans of a scope are not a list here:
--max-spans-per-request caps them, because a Collector puts thousands in one scope. In OTLP/JSON, every array but resourceSpans[].scopeSpans[].spans counts (D273). A protobuf field that holds one message and comes twice is a 400. import has the same flag.
Why: the macOS allocator keeps the memory of a decoded very long list after the request. 16 requests of one span with 3,500,000 empty attributes left 3.4 GB before this cap. Now they are refused and leave 24 MB (F78, results/anu84-hardening/list-cap-retention.json). Not measured on Linux.
Memory under load
The memory of the writes in flight is at most 16 bodies, with their decoded and mapped forms. The bodies and the mapped spans are not in the decode budget. Measured on one Mac (F99, the peak footprint of the server):
No SDK sends the last shape. On a small machine, lower the SDK’s batch together with
--max-body-bytes and --max-mapped-bytes. See Memory and threads.
Other limits
- An export has no time limit and no size limit, and it holds one thread while it runs, also while a slow client reads. The number of exports at one time has no limit.
- No rate limit. Without
--auth keysthere is no authentication, and without--tls-*no TLS: use a private network, or a proxy that does both. - API keys have no expiry date and no per-key limits. To revoke a key, remove its line (in effect within about 2 s).
- One store, one folder, one writer: a second writer is refused. With
--tenants-dir, one server per tenants folder. With--s3, one writer per prefix. - Tenants: other tenants’ first requests wait while a tenant store opens or closes (ms; longer if a close waits for a merge). Each tenant that writes commits on its own 0.5 s timer, so commits and disk flushes grow with the number of tenants that write at once.
- Numbers in JSON answers are plain JSON numbers:
costNanossums above 2^53 lose precision in JavaScript. - What the mapping does not keep: Mapping.
- Speed of the server was not measured. Do not read numbers from the tests.
Server flags
Every flag and its default.
Errors, memory and threads
What each error means. How much memory to give.