Skip to content

Choosing a Flush Mode

Flush modes control when data is fsync’d to disk. The right choice depends on power stability and data criticality.

ModeBehaviorData at RiskUse When
normalBatch sync every ~50 writesUp to 49 entriesStable power, maximum throughput
cautiousSync after each writeNone (after call returns)Elevated risk, possible brown-outs
emergencySync immediately, pause compactionNonePower failure imminent

Use normal when the power supply is stable and throughput matters more than per-entry durability. Normal mode amortizes fsync cost over ~50 writes, yielding roughly 7x the throughput of Cautious mode. Up to 49 entries can be lost if power fails between syncs.

Use cautious when handling financial transactions or any data where loss is unacceptable. Every append() call fsyncs before returning. If append() returns without error, the entry is on disk. This is the recommended mode for POS terminals.

Use emergency when a UPS signals low battery or power loss is imminent. Behaves like Cautious but also pauses background compaction to minimize disk activity. Switch to this mode at runtime via SIGUSR1.

Terminal
kifa ingest --stdin --flush-mode cautious -d ./data
ModeThroughput BottleneckNotes
normalpwrite syscall + memtable flushfsync amortized over 50 writes; ~7x cautious
cautiousStorage fsync latencyOne fdatasync per append; hardware-dependent
emergencySame as cautiousCompaction pause has no measurable impact

Throughput scales with storage hardware. Run cargo bp on the target device for specific numbers.