ambarltd / emulator

A local version of Ambar
2 stars 0 forks source link

Create Topic abstraction #2

Closed lazamar closed 1 month ago

lazamar commented 1 month ago

The semantics and guarantees here are analogous to Kafka's.

Benchmarks

A Topic can use any kind of partition. The benchmarks were run with the file-backed partition implementation. Run with ./utils.sh bench-save

benchmarking queue/topic/write 10000 messages to 1 partition in series
time                 29.56 ms   (29.19 ms .. 29.83 ms)
                     0.999 R²   (0.999 R² .. 1.000 R²)
mean                 29.52 ms   (29.30 ms .. 29.80 ms)
std dev              487.5 μs   (395.5 μs .. 647.5 μs)

benchmarking queue/topic/write 10000 messages to 5 partitions in series
time                 35.45 ms   (35.05 ms .. 35.84 ms)
                     0.999 R²   (0.999 R² .. 1.000 R²)
mean                 34.84 ms   (34.41 ms .. 35.16 ms)
std dev              733.5 μs   (560.5 μs .. 1.017 ms)

benchmarking queue/topic/write 10000 messages to 10 partitions in parallel
time                 72.30 ms   (72.17 ms .. 72.45 ms)
                     1.000 R²   (1.000 R² .. 1.000 R²)
mean                 72.46 ms   (72.35 ms .. 72.69 ms)
std dev              297.7 μs   (191.8 μs .. 435.3 μs)

Tests

unit
  queue
    partition
      reads what is written [✔]
      reopens [✔]
      no concurrent opens [✔]
      blocks reads when reaches the end [✔]
      reads concurrently [✔]
    topic
      1 consumer reads from 1 partition [✔]
      1 consumer reads from 2 partitions [✔]
      2 producers write to 1 partition [✔]
      allows consumers without readers [✔]
      reads ordered per partition [✔]
      rebalance splits partitions between consumers [✔]
      rebalance joins partitions in consumers [✔]
      rebalance rewinds to last comitted offset [✔]