Both thresholds apply to the size of the serialized document on disk, including all CRDT bookkeeping, not the size of the JSON you pass into your write. Maps, registers, counters, and tombstones from prior updates all count toward the size.
Earlier SDK versions. Before SDK 5.1, the hard limit is not enforced: a write that exceeds it succeeds, and the Dropping a replication diff on receipt applies to SDK 5.2 and later.
ditto-small-peer-store component logs an error-level message instead. Search the logs for future limit to find these documents:Why the limits exist
Ditto is a peer-to-peer CRDT database designed to sync over constrained transports — Bluetooth Low Energy, lossy LAN, intermittent WAN. Every document is the unit of CRDT merge and, in most transports, the unit of replication framing. Two costs scale super-linearly with document size:- Merge cost. When two peers reconcile divergent edits to the same document, the merge cost is a function of the size of the document, not just the size of the change. A 5 MiB document with a one-byte field update still pays the cost of a 5 MiB merge.
- Mesh framing. Replication breaks documents into smaller parts before sending them, and reassembles on the receiver. On Bluetooth LE, the effective throughput is roughly 20 KB/s — a 250 KiB document can take 10+ seconds to replicate for the first time, and a 5 MiB document can take minutes. Until the receiver has every part, the document does not appear in query results.
ATTACHMENT CRDT data type instead. Attachments are content-addressed, fetched lazily, and not subject to the document-size thresholds.
Monitoring
Documents that exceed the soft limit are reported in your application logs, and a write that exceeds the hard limit fails with an error. Look for log lines from theditto-small-peer-store component:
-
warnlevel — soft limit exceeded: -
Hard limit exceeded — the write fails with an error. The error message contains:
For an
UPDATE, it containsUpdate failed:instead.
_id = together with recommended limit is enough to surface the documents over the soft limit. Hard-limit violations are returned to your application as write errors.
Remediation
Split documents into smaller pieces
If a document has grown unbounded because you’re appending into a nested map (e.g. a list of orders inside a customer document), the data model is the problem, not the document. Split the nested data into its own collection and use the parent’s_id as a foreign key. See Data Modeling Tips for examples.
The flat model also tends to be a better fit for Ditto’s CRDT merge semantics: changes to one item don’t force every peer to re-merge the entire parent document.
Move binaries to the ATTACHMENT type
If the document is large because it embeds a binary payload — an image, a PDF, a serialized blob — move that field to an ATTACHMENT. Attachments live outside the document body and are not counted against the size thresholds.
DQL
A note on already-oversized documents
CRDT merge state carries tombstones for prior writes, so writing a smaller value into an oversized document does not immediately reduce its serialized size — the tombstones from earlier larger values remain part of the document until they are eventually compacted out. A document that is already oversized in steady state is unlikely to shrink back under the limit through ordinary edits alone. The most reliable remediation for a critically oversized document is to write a fresh, smaller document under a new_id and update any references; structural changes to the offending data model (splitting into a sub-collection, moving binaries to ATTACHMENT) are the durable fix.
Configuring the limits
Both thresholds are exposed as system parameters and can be inspected and changed at runtime viaALTER SYSTEM:
DQL
Cross-peer consistency
Both parameters must be set to the same value on every peer in your mesh, including any cloud peers. The thresholds are evaluated locally, so an inconsistency leads to:- Soft limit mismatch: different peers log warnings for different documents — confusing, but not data-impacting.
- Hard limit mismatch: a peer with a higher local limit will write and attempt to replicate a document that a peer with a lower local limit refuses. The lower-limit peer drops the update, and the document gets no more updates on that peer until it’s evicted and synced again.
Enforcement behavior
The hard limit is enforced:- A user write that makes a document exceed the local hard limit fails with an error from
execute. Catch it the same way you catch any other DQL error.
See also
Data Modeling Tips
Modeling patterns that keep individual documents small and replication fast.
ATTACHMENT type
The
ATTACHMENT CRDT for binary payloads that don’t count against document-size limits.Customizing System Settings
Use
ALTER SYSTEM to inspect and change document_size_*_limit_bytes at runtime.