i2goSignals

Two-node cluster: throughput and coordination findings

Measured 2026-09-29 on the benchmark stack (docker-compose-benchmark.yml with --profile cluster, so goSignals1 and goSignals1b share cluster bench and the three-member Mongo replica set). Same host and images as the single-node algs-*-c128 rows in e2e-history.md. The bench alternates its pushers between the two nodes (--gs1b), so both nodes ingest for every stream while only one node (the lease holder) delivers.

Throughput

20000 events, 128 clients, three receivers (PUSH, POLL, SSTP initiator). Ingest ev/s is the acknowledged rate across both nodes. Delivery columns are the drain time after the last acknowledgement.

Run Nodes Durability Alg Ingest ev/s p50 / p99 ms Split gs1 / gs1b PUSH drain s POLL drain s SSTP
algs-RS256-c128 1 local RS256 3406 37.0 / 69.8 - 0.5 0.5 0.5 s
algs-ES256-c128 1 local ES256 4140 30.5 / 61.0 - 0.5 0.5 0.5 s
algs-RS256-majority-c128 1 majority RS256 2714 45.4 / 101.3 - 0.5 0.5 0.5 s
bench-stack-c128-20k-majority-es256 1 majority ES256 3480 34.7 / 110.7 - 0.5 0.5 0.5 s
cluster-local-RS256-c128 2 local RS256 2510 32.9 / 253.3 5217 / 14783 38.4 6.1 3706/6666 at 300 s
cluster-local-RS256-c128-run2 2 local RS256 5027 21.5 / 76.5 7197 / 12803 38.5 5.6 4782/6666 at 90 s
cluster-local-ES256-c128 2 local ES256 5244 21.2 / 67.0 7675 / 12325 40.9 4.6 4469/6666 at 300 s
cluster-majority-RS256-c128 2 majority RS256 3782 29.0 / 91.6 7088 / 12912 32.4 5.1 4923/6666 at 300 s
cluster-majority-ES256-c128 2 majority ES256 4635 24.9 / 66.3 8063 / 11937 33.5 4.6 5011/6666 at 300 s

The first cluster-local-RS256-c128 row has a p99 seven times its neighbours and the most skewed split; it was the first run after the second node’s restart and is kept as an outlier, not a result.

Reading the table:

Rows marked (defect, see cluster-perf.md) in e2e-history.md are the runs that exposed defects A and C; their delivery numbers are not cluster throughput, they are the defect.

What happens when many clients push to one stream

The question behind these runs: a transmitter opens many parallel connections to one inbound stream, possibly spread over both nodes. What the router guarantees, and where it does not.

Defects found

The two-node runs found four problems. None of them is visible on one node. The bench and the bench compose were changed so the measurements above are valid; the server-side fixes are proposals, not done.

A. Peers learn of new streams only every 40 s (#349)

A node loads the stream table at start and refreshes it from the backgroundSync ticker: every 10 s it refreshes state, every fourth tick it calls InitializeReceivers and picks up new streams. A SET that arrives on the peer before then matches no outbound stream: it is stored, acknowledged with 202, and never delivered, because no pending marker was written for it.

Measured: the cluster-local-RS256-c128-unsynced row delivered exactly goSignals1’s share of the SETs; goSignals1b’s share (about half) was stored and lost to delivery. The bench now waits after creating its streams until goSignals1b’s /metrics names them (-gs1b-sync-timeout, 90 s default; observed 9.6 to 36.9 s).

Fix proposal: refresh the table on demand when a SET matches nothing (plan against the store when the cache is stale), or have the creating node broadcast stream-created on the internal listener. The ticker stays as the fallback.

B. A node advertises its peer’s address (#348)

registerNode builds the wake-up address from the host of BASE_URL, the port from I2SIG_CLUSTER_INTERNAL_PORT (else the main port), always http://. The shipped docker-compose-cluster.yml and docker-compose-cluster-dev.yml give both nodes BASE_URL=https://gosignals1:8888/ and set no internal port, so both nodes advertise http://gosignals1:8888: the second node names the first, and the scheme is plain HTTP against a TLS listener. Every wake-up call fails with Wake-up call failed, and cross-node delivery falls back to the 1 s backfill (PUSH, POLL) or stalls (SSTP, defect D).

Fixed in docker-compose-benchmark.yml only: a shared I2SIG_CLUSTER_INTERNAL_TOKEN, I2SIG_CLUSTER_INTERNAL_PORT=8898, and a per-node BASE_URL on goSignals1b. Verified in cluster_nodes (http://goSignals1:8898, http://goSignals1b:8898). The shipped cluster composes still have the defect.

Fix proposal: a per-node advertise address (I2SIG_CLUSTER_ADVERTISE_URL, default derived as today) and a start-up warning when two live nodes advertise the same address; fix the two shipped cluster composes.

C. Stream deletion never reaches peers (#350)

backgroundSync adds and updates streams; it never removes one. After the bench deleted its streams, goSignals1b kept them, took over the push lease of a deleted stream 8 s after goSignals1 deleted it, and in every later run fanned out the new SETs to the stale streams: thousands of orphan pendingEvents markers per stale stream (4470 to 4877 observed), pushes to the removed receiver (RFC8935Error not_found), Error updating remote address ... not found, and finally a state transition on a stream that no longer exists. The cluster-local-RS256-c128-stale-peer-streams row was measured in that state: the peer did about twice the fan-out work per SET. (Its 40 s push drain is defect D, not C; the clean runs show the same.)

Also never cleaned: cluster_nodes rows for nodes that are gone, and cluster_leases rows for streams that are gone.

The bench works around it by restarting goSignals1b before each two-node run. That clears its memory; the orphan markers stay in Mongo and are inert.

Fix proposal: backgroundSync reconciles against the store (drop what the store no longer has, release its lease, stop its loop); the deleting node also broadcasts stream-deleted on the internal listener. A lease or node row older than a few TTLs is garbage-collected by whoever notices it.

D. The cross-node hand-off is a signal without a payload (#347)

When the non-owning node ingests a SET for a stream the other node delivers, it sends the owner a wake-up call carrying only the stream id and mode, coalesced to one call per stream per 250 ms. On the owner the wake is a one-slot, non-blocking channel signal (Wakeup() drops the signal if the loop is busy). What the loop then does decides the throughput:

Fix proposal, in order of leverage:

  1. Make the wake level-triggered: on a wake, PUSH backfills regardless of buffer depth and repeats until a read returns fewer than a batch; the SSTP dialer loops ClaimOutbound until a claim comes back empty after the wake that started it, and re-checks once more when a second push completes.
  2. Give the SSTP dialer the same 1 s backfill ticker the push loop has while it holds undelivered work, as the safety net.
  3. In local mode, re-wake the target from commitWalEntry when the drained SET’s stream is owned elsewhere, or defer the ring-fed wake for remote owners until commit.
  4. Optionally carry the JTIs in the wake body (the coalescing window can batch them), so the owner submits them without a Mongo read at all.

Status (#347): items 1 to 3 are fixed; item 4 is deferred.

The two-node numbers after the fix are pending a bench run (PUSH and SSTP, majority and local). The measurements above predate the fix.

  1. D (#347, hand-off) and B (#348, advertise address). D caps cross-node PUSH at about 100 SETs per second and stalls cross-node SSTP in both durability modes; B breaks every wake-up in the shipped cluster composes today, which turns D into the only delivery path.
  2. A (#349) and C (#350) together, as one “stream table reconciliation” change: the peer’s table should follow the store, in both directions, faster than 40 s.
  3. Backfill gating and the one-strike lease renewal are tuning, not defects; revisit after 1 and 2 with a two-node soak.

The two-node numbers above measure ingest scaling only, because they were taken before D was fixed. Until the post-fix bench run is recorded, the single-node rows remain the reference for delivery.