Skip to content

Centrifuge (Centrifugo) Redis broker: history Lua scripts, stream reads and SUBSCRIBE 1.5-3x slower than Redis 8 #900

Open

Description

@murtazayusuf

Summary

Centrifuge v0.40.1's own Redis benchmarks (the engine behind Centrifugo, ~11k stars) run slower on KiviDB 1.2.2-lua than on Redis 8, in both default and --threads 4 mode. The gap is widest on the Lua history paths and on stream reads. KiviDB was forced to single-client mode because of the CLUSTER SLOTS issue.

Setup: one 8 vCPU box, server pinned to 4 cores, benchmark process on the other 4, PARALLELISM 16 and 128, -benchtime 5s -count 2. Values are ns/op, lower is better, shown as par16 / par128:

Benchmark Redis 8 Valkey 8.1 io4 KiviDB t4
Publish_ManyCh (plain PUBLISH) 15.7k / 698 12.6k / 794 17.5k / 799
Publish_History_1Ch list (Lua) 9.2k / 8.3k 10.4k / 9.2k 14.5k / 14.1k
Pub_History_ManyCh list (Lua) 9.8k / 9.0k 11.0k / 9.7k 14.9k / 14.6k
Pub_History_ManyCh stream (Lua) 12.4k / 11.6k 12.6k / 11.4k 15.5k / 15.2k
History_1Ch list 7.3k / 6.2k 7.5k / 6.4k 12.7k / 12.2k
History_1Ch stream (XRANGE in Lua) 13.8k / 13.0k 12.7k / 12.2k 24.5k / 23.7k
Recover_1Ch stream 37.7k / 39.7k 27.4k / 26.9k 46.4k / 45.5k
Subscribe 3.2k / 954 3.5k / 997 10.8k / 925

Notes:

  • In non-cluster mode, centrifuge's history scripts touch 2–3 keys without a hash tag, such as centrifuge.stream.<ch> and centrifuge.stream.meta.<ch>. They likely hit the serialized path (Single-key Lua scripts without a hash tag run serialized and drag the whole workload: Nextcloud 0.65x Valkey, p99 13 ms (vs 1.9) #880). Even so, a single channel (_1Ch) is ~1.6× slower than Redis per call, and --threads 4 gives nothing over the default.
  • Stream reads in Lua (XRANGE/XREVRANGE with COUNT) are ~1.8× Redis.
  • Subscribe at par16 is ~3× Redis.
  • Compat: the centrifuge integration suite has identical results on Redis and KiviDB t4 (once single-client mode is forced).

Reproduce with go test -tags integration -run '^$' -bench 'BenchmarkRedis.*/rd_single' . in centrifuge v0.40.1 against a server on 127.0.0.1:6379.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions