Skip to main content

Benchmarks

These numbers give an order of magnitude, not a promise: they come from one machine, and the fsync = always results depend almost entirely on how fast the disk flushes.

Machine and method​

  • Machine: Apple M5 (10 cores), 16 GB of memory, macOS 26.6.2, internal SSD (APFS).
  • Build: release, with group commit.
  • Method: each scenario runs for 2 seconds in its own temporary data folder, deleted at the end. Latencies go into a fixed-size histogram and reads are done in 1 MiB batches, so memory stays bounded: the whole run took 40 s and 9.8 MB of memory at most (maximum resident set size).

The benchmark program lives in bench/ and uses only the public API. To run it on your machine:

cargo run --release -p mojay-bench
# one scenario, for longer
cargo run --release -p mojay-bench -- --only "produce never" --seconds 5

Results​

scenariomessagesmsg/sMiB/slatencyp50p99
produce always, 100 B, batch 16153070.0per send3.1 ms5.2 ms
produce always, 1024 B, batch 15532760.3per send3.9 ms5.2 ms
produce always, 100 B, batch 10054,10027.0 k2.6per batch4.2 ms5.8 ms
produce interval 100ms, 100 B, batch 1783,387391.7 k37.4per send2 µs6 µs
produce interval 100ms, 1024 B, batch 1476,972238.5 k232.9per send3 µs12 µs
produce interval 100ms, 100 B, batch 10012,924,7006.45 M615.0per batch9 µs49 µs
produce never, 100 B, batch 1885,637442.8 k42.2per send2 µs5 µs
produce never, 1024 B, batch 1563,309281.7 k275.1per send3 µs9 µs
produce never, 100 B, batch 10011,433,4005.69 M542.4per batch9 µs74 µs
1 writer on 1 partition, always, 100 B5532760.0per send3.9 ms6.3 ms
2 writers on 1 partition, always, 100 B6083040.0per send7.3 ms9.4 ms
4 writers on 1 partition, always, 100 B1,1625800.1per send7.3 ms11.5 ms
1 writer on 1 partition, never, 100 B839,886419.9 k40.0per send2 µs6 µs
2 writers on 1 partition, never, 100 B528,189264.1 k25.2per send3 µs90 µs
4 writers on 1 partition, never, 100 B554,996277.4 k26.5per send3 µs360 µs
read raw (TopicReader), 100 B300,0005.42 M516.7
read with a consumer group, 100 B300,0004.86 M463.3
producer → consumer latency, always, 1,000 msg/s2,0002860.0delivery4.7 ms10.5 ms
producer → consumer latency, never, 1,000 msg/s2,0001,0000.0delivery721 µs2.6 ms

The latency columns measure different things depending on the row:

  • per send and per batch: the time a send call takes;
  • delivery: the time from just before send until the message comes out of the consumer's poll.
Read numbers vary

Read throughput varies a lot from run to run on the same build: 5 to 15 million messages per second raw, 5 to 9 million through a consumer group. It depends on the state of the page cache right after the topic is filled. Take the read rows as an order of magnitude.

Before group commit​

The same machine, with the flush done under the partition's write lock (and the index flushed on every send):

scenariomsg/sp50p99
produce always, 100 B, batch 12055.2 ms9.4 ms
produce always, 100 B, batch 10014.6 k7.3 ms10.5 ms
1 writer on 1 partition, always, 100 B1486.3 ms14.7 ms
2 writers on 1 partition, always, 100 B1486.3 ms335.5 ms
4 writers on 1 partition, always, 100 B1686.3 ms805.3 ms

Write path and group commit explains the change.

What the numbers say​

  • always is bounded by the disk flush: about 300 messages per second for a producer sending one message at a time. On macOS each fsync is an F_FULLFSYNC, which really empties the drive's cache, and takes about 3 to 5 ms. Batching amortizes it: batches of 100 messages reach 27,000 msg/s, with the same latency per call.
  • Group commit lets concurrent writers share flushes. With 4 writers on one partition, always reaches about 580 msg/s, 3.5 times as much as before, and the p99 latency drops from 805 ms to 11.5 ms. The write lock is now held for microseconds, so the unfairness of flock no longer shows. Single writers got faster too: a send now flushes only the .log, not the index, which is a cache rebuilt from the log.
  • interval and never are about 1,000 times faster: 250,000 to 450,000 single sends per second, 5 to 6 million per second in batches of 100, a few microseconds per send. With never, contention between writers costs about a third of the throughput and adds latency in the hundreds of microseconds.
  • Reading is fast: 5 to 15 million messages per second raw, 5 to 9 million through a consumer group.
  • Delivery latency from producer to consumer is under 1 ms at the median and under 3 ms at p99 with never. With always, it is dominated by the flush.
Need more throughput with always?

Each writer gets about 300 sends per second on this machine. To go beyond, send in batches, let several writers share flushes, or choose fsync = interval if losing the last interval on a power loss is acceptable. See Durability.