i2goSignals

Event store fast path — two-stage, split, or tune Mongo? — research note

Date: 2026-09-26 Status: research only. No code, ADR, or issue follows from this note.

TL;DR

Ingest is bound by one majority-acked, journaled MongoDB replica-set round trip per accepted SET, not by document count, document size, or the Go code around it.

1. The write path today (verified)

2. How events are read later (verified)

Reader Calls Cite
Push worker GetEventIds (→ GetPendingForStream) then GetEventRecords (→ FindByJTIs), deliver, AckEvents(r.ctx, ackJtis, sid, fencingToken) event_router.go:2284-2289,2416-2540; event_service.go:286,307-308,343-361
Poll handler AckEvents for the client’s ack list, GetEventIds, GetEventRecords event_router.go:1529-1576,1630-1632
SSTP outbound same trio sstp_outbound.go:219,380,527
Ack RemovePendingMany + MarkDeliveredMany event_service.go:348,356
Retention ListDeliveredForStream → RemoveDelivered → DeleteBodyIfUnreferenced (counts pending and delivered refs, then DeleteOne on events) retention.go:113-150; mongo/event_dao.go:553-592
Wake-up WatchPending change stream on pending event_router.go:454; mongo/event_dao.go:607-661

Every read is keyed by JTI or by {sid, jti}; none reads the body by time range on the hot path. That is what makes a JTI-keyed side store plausible at all.

3. Cluster model and in-flight events (verified)

4. What “safely stored” must mean (spec text)

5. Candidate stores (from their own docs)

Store License CGO Durability knob Own benchmark numbers Maintenance (gh api, 2026-09-26)
Mongo w:majority (today) — — majority + journal fsync on each member [MDB-WC; MDB-JOURNAL] ADR 0038: ~9 ms per write server-side on dev RS [ADR-0038] —
Mongo w:1, j:true — — primary journal fsync only; “can be rolled back if the primary steps down before the write operations replicate” [MDB-WC] none in repo —
Mongo w:1, j:false — — journal synced every 100 ms (commitIntervalMs) [MDB-JOURNAL] none in repo —
etcd-io/bbolt MIT pure Go two fsync() per tx; DB.Batch “opportunistically combined into larger transactions” (must be idempotent); NoSync escape hatch; “random writes can be slow” [BBOLT] no primary benchmark found pushed 2026-09-15, 9757 stars, active
hypermodeinc/badger v4 Apache-2.0 “Pure Go (no Cgo)” [BADGER] SyncWrites default false; writes via mmap “survive process crashes”; true adds an msync “to survive hard reboots. Most users of Badger should not need to do this.” [BADGER-OPT] referenced to badger-bench, no numbers in README pushed 2026-09-23, 15773 stars, active
cockroachdb/pebble BSD-3-Clause not stated in README WriteOptions.Sync: “required for durability of individual write operations but can result in slower writes”; unsynced “a recent write may be lost” [PEBBLE-OPT] none published in README pushed 2026-09-26, 6043 stars, CockroachDB production since v20.1 [PEBBLE]
tidwall/wal MIT pure Go (inferred: no cgo in module) NoSync default false, fsync after each write; WriteBatch writes several entries in order [WAL-OPT] no primary benchmark found pushed 2025-08-31, 734 stars — 13 months idle
Redis AOF appendfsync always — — group commit: “single write and a single fsync (before sending the replies)”; “Very very slow, very safe”; AOF is local, not replication [REDIS] none quoted —
Hand-rolled WAL + in-memory JTI index — pure Go one fsync per group commit, exactly Redis’s model none ours to maintain

Notes:

6. Design analysis

6a. Two-stage store (local staging, async drain)

6b. Split store (raw bytes permanently in a fast store, metadata in Mongo)

6c. Tune the existing Mongo path

7. What the current numbers do and do not say

8. Recommendation

  1. Instrument, then (c). Add the DAO histogram and the fsync probe; run the three benches in §7. Prototype the group-commit decorator behind interfaces.EventDAO [dao_interfaces.go:75] and wire it at the two provider sites [memory_provider/provider.go:138; mongo_provider/provider.go:189]. This is the only option that raises throughput without touching what 202 means.
  2. Do not do (b).
  3. Treat (a) as an opt-in durability mode, not the default. Prototype it only if (c) still leaves the majority round trip as the ceiling and an operator has a stated tolerance for “events acked on one node’s disk”. Use tidwall/wal (simplest, MIT, matches the append-then-truncate shape) or bbolt (better maintained, DB.Batch gives group commit for free); reject badger for its SyncWrites=false default. Ship it with the WAL cap, the drain-order rule for pending, and the metrics in §6a, and document on the stream that a node loss can lose acked events until the node returns.

Acknowledgement-contract risks, in one list:

Unverified claims (summary)

Sources

Repository (i2goSignals, branch release-0.12.0 @ cf069cb):

External: