Skip to main content

What an error means

Every error of the API is {"error": "message"}. The message never quotes the request: a prompt or an email in a filter does not come back, also not in logs. It names the place and the kind of problem, and a short hash of what it cut out. Each limit is a flag: Server reference, “Run it” and “Limits”. In the library (Rust, Node, Python) an error is an exception with the full message.

Memory and threads

Write memory

  • The write path of one store: a writer heap of 256 MB and a write queue of 256 MB. The store keeps its write memory to about 2 to 3 times the queue plus the heap. That is a rule of the code, not a measured peak.
  • A tenant store gets 32 MB + 32 MB, so about 100 to 130 MB at most while it takes writes (by the same rule; not measured). Keep --max-open-tenants under the thread limit of your system (next section).
  • Merges in the background use memory that these limits do not cover.
  • The memory of the requests in flight has its own budget: --ingest-memory-mb (512) for the decodes of writes. The bodies (at most 16 at once, each at most --max-body-bytes) and the mapped spans are not in it: 16 full SDK batches of 50 KB model calls at once take about 1.3 GB, and 16 bodies of 64 MiB about 2.7 GB (F99).
  • Queries have no memory budget yet (Limits).
  • Memory of an import: --memory-mb, with measured peaks in Server reference, “Import old traces”.
On a small machine (or a container with 1 GB of memory), lower the SDK’s batch (OTEL_BSP_MAX_EXPORT_BATCH_SIZE, for example 128) together with --max-body-bytes and --max-mapped-bytes. A --max-body-bytes below the SDK’s full batch refuses that batch with 413, and the SDK does not send it again.

Threads, with tenants

One open store holds 13 threads and one more for each CPU up to 8 (21 on a machine with 8 or more CPUs, 17 with 4). Count --max-open-tenants x that number, plus the server’s own (about 40 when idle; up to 512 more while many requests wait for a store), plus the reserve. The limit is kern.num_taskthreads on macOS (6,144, per process) and on Linux the pids limit of the container (pids.max of its own cgroup: Docker --pids-limit; it counts the threads of every process in the container), ulimit -u and /proc/sys/kernel/threads-max. For the default of 100 open stores set the pids limit to 4,096 or more (100 x 21 + 512 + 512 = 3,124), or leave it unlimited.
A pids limit of a Kubernetes POD (podPidsLimit) is not seen: on cgroup v2 a container sees only its own cgroup, and the limit of the pod is in the cgroup above it. The server then writes no warning and makes no check before an open; it still answers 503 THREADS when an open gets no thread, and opens a failed store again. With a limit of the pod, set --max-open-tenants by hand: threads of one store x stores + the server’s own threads (about 40, and up to 512 more under load) must stay under the limit.

What the server does at the limit

At its start it writes a WARNING line when --max-open-tenants does not fit the limit it reads, with the number of stores that fit. Before it opens a tenant’s store it reads the limit again: with no room for the threads of one store and the reserve (an eighth of the limit, 16 to 512), it closes the store used longest ago first; while every open store is in use the request gets 503 with a text that starts with THREADS: and Retry-After: 1, and no folder is made for a new tenant. The reserve is there so that the commits of the open stores keep their threads. If a commit gets no thread all the same (another process of the container took them): that store stops taking writes (503), and the next request for its tenant opens it again, as a restart does. A query waits up to 1 s for the other requests of the tenant to end; a write never waits (it gets 503 at once while another request holds the store). The writes that were answered OK before are in the write log and are shown after that open. Until then, queries of that tenant answer from its last commit. A stop of the server opens such a store once more and closes it: the exit code is 0 when that works; when not, a log line names the tenant, and the next start applies its write log.