Write-Heavy Workloads

Write-heavy workloads stress the mutable segment, WAL, and maintenance pipeline.

Main Controls

Tune:

  • WAL mode,
  • mutable segment max item count,
  • maintenance behavior,
  • disk segment size,
  • compression,
  • serializers.

Symptom Guide

SymptomLikely pressureFirst actions
Process memory grows during heavy writesmutable or read-only in-memory segments are too largelowerMutableSegmentMaxItemCount; keep a maintainer alive; check value size
Many read-only segments accumulatemaintenance is not keeping upstart/keepCreateMaintainer; lower mutable segment size; inspect merge duration
Writes are slower than expectedWAL mode, serializer cost, compression, storage latencyuseUpsert; avoid unnecessary atomic/transaction APIs; benchmark WAL modes
Merge takes too longdisk IO, compression, large values, large segment sizereduce value size; tune compression; review disk segment sizing
WAL files growmutable segments are not being merged/compacted, or transaction logs retain historykeep maintenance healthy; review transaction cleanup and backup settings

Use The Fast Path

UseUpsertfor simple writes. Avoid transactions or atomic methods unless the correctness rule requires them.

zoneTree.Upsert(key, value);

Mutable Segment Size

Larger mutable segments can improve write batching and reduce merge frequency, but they use more memory.

The default mutable segment limit is1_000_000records. That is a good general-purpose default for compact values. For large strings, JSON documents, or object payloads, tune it by expected byte size instead of treating1_000_000records as a memory budget.

Large values should use a lowerMutableSegmentMaxItemCount.

WAL Mode

The default async compressed WAL is usually the right starting point for write-heavy workloads. It keeps WAL protection enabled while allowing very high throughput through background WAL writes and compression.

Use sync WAL modes only when the application needs synchronous WAL acknowledgment. UseNo WALonly for cache, temporary, or intentionally rebuildable data.

Maintenance Throughput

If read-only in-memory segments accumulate, maintenance is not keeping up. Consider:

  • lowering mutable segment size,
  • increasing maintenance activity,
  • reducing compression cost,
  • checking storage bandwidth,
  • reducing value size.
using var maintainer = zoneTree.CreateMaintainer();

maintainer.MaximumReadOnlySegmentCount = 32;
maintainer.ThresholdForMergeOperationStart = 500_000;

Disk Segment Shape

For very large write-heavy databases, multipart disk segments help keep physical segment files manageable. Tune disk part sizes only after observing merge duration, file count, backup behavior, and read latency.

The default disk segment max item count is20_000_000records. Multipart disk segments target1_500_000to3_000_000records per part by default.

See disk segment tuning and write amplification.