Skip to content

Commit 6b136f7

Browse files
committed
docs: update routing strategy comparison with resilient stickiness and churn mitigation findings
1 parent 26f8489 commit 6b136f7

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

docs/routing_strategy_comparison.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Relay Route Selection: Architectural Evaluation (MOLS vs. Rendezvous Hashing)
22

33
This document provides a comparative analysis of relay selection algorithms evaluated for `portal-tunnel`:
4-
1. **MOLS (Mutually Orthogonal Latin Squares)**: Dynamic finite-field combinatorial grid allocation.
5-
2. **HRW (Highest Random Weight / Rendezvous Hashing)**: Independent pseudo-random weight mapping ($W = \text{hash}(c, r)$).
4+
1. **MOLS (Mutually Orthogonal Latin Squares)**: Dynamic finite-field combinatorial grid allocation with resilient active-connection stickiness.
5+
2. **HRW (Highest Random Weight / Rendezvous Hashing)**: Independent pseudo-random weight mapping ($W = \text{hash}(c \mathbin{\Vert} r)$).
66

77
Both algorithms were evaluated under identical synthetic network conditions to measure load distribution, failure isolation, and operational overhead.
88

@@ -13,36 +13,37 @@ Both algorithms were evaluated under identical synthetic network conditions to m
1313
### MOLS (Mutually Orthogonal Latin Squares)
1414
- **Concept**: Arranges relays and clients into an $N \times N$ discrete grid where $N$ is the candidate pool size. Multipliers $(m_1, m_2)$ coprime to $N$ form two orthogonal Latin squares to assign coordinates to relays.
1515
- **Design Intent**: Seeks mathematically exact uniform dispersion across both primary and secondary candidate slots, minimizing initial load variance across static topologies.
16-
- **Hypothesis**: Given a known, relatively stable cluster, combinatorial orthogonality provides provable deterministic spreading without relying on probabilistic hashing balance.
16+
- **Reshuffle Defense Mechanism**: To prevent the $\approx 81\%$ reshuffle storm when $N$ changes ($N \to N-1$), MOLS relies on **resilient active-connection stickiness** in `applyActiveStickiness`. Established healthy listener connections are retained in priority order, cutting unaffected client churn to 0% as long as nodes remain healthy and unpressured.
1717

1818
### HRW (Highest Random Weight / Rendezvous Hashing)
1919
- **Concept**: Evaluates an independent 64-bit pseudo-random weight function $W(c, r) = \text{hash}(c \mathbin{\Vert} r)$ for every client-relay pair and sorts descending.
20-
- **Design Intent**: Prioritizes monotonicity (minimal disruption) and robustness in asynchronous, gossip-based discovery environments where candidate pools change dynamically.
21-
- **Hypothesis**: A stateless volunteer network experiences frequent membership changes ($N \to N-1$). Monotonicity ($1/N$ migration) prevents global reconnection storms and provides robust degradation regardless of whether nodes share a consistent view of $N$.
20+
- **Design Intent**: Prioritizes intrinsic monotonicity (minimal disruption) and robustness in asynchronous, gossip-based discovery environments where candidate pools change dynamically.
21+
- **Hypothesis**: A stateless volunteer network experiences frequent membership changes ($N \to N-1$). Intrinsic monotonicity ($1/N$ migration) prevents global reconnection storms mathematically without requiring stateful connection-tracking stickiness or identical cluster views across clients.
2222

2323
---
2424

2525
## 2. Empirical Benchmark Results
2626

2727
Evaluated across 700 synthetic clients on 7 relays ($N = 7$), as well as even non-prime orders ($N = 6$):
2828

29-
| Scenario & Metric | Baseline MOLS (`main`) | Dual-Orthogonal MOLS (PR #354) | HRW Rendezvous (PR #356) |
29+
| Scenario & Metric | Baseline MOLS (`main`) | MOLS + Dual Orthogonal + Resilient Stickiness (PR #354) | HRW Rendezvous (PR #356) |
3030
| :--- | :---: | :---: | :---: |
3131
| **Primary Load Distribution** ($N=7$, 700 clients)<br>*(Min ~ Max, Ideal: 100 / 14.3%)* | 98 ~ 103 (Peak: 14.7%) | 82 ~ 118 (Peak: 16.9%) | 90 ~ 110 (Peak: 15.7%) |
3232
| **Primary Chi-Square Statistic ($\chi^2$)**<br>*(Lower indicates closer to uniform)* | **0.16** | 7.78 | 4.74 |
3333
| **Secondary Herd Concentration**<br>*(Busiest primary node drops; 2nd-place distribution)* | **1 node (100.0% stampede)**<br>❌ Total herd collapse | 6 nodes (Max share: 28.8%)<br>✅ Orthogonally dispersed | 6 nodes (Max share: 20.9%)<br>✅ Statistically dispersed |
34-
| **Unaffected Client Reshuffle on Node Drop**<br>*($N=7 \to N=6$, clients not on dropped node)* | **82.4% reshuffled** (492 / 597)<br>❌ Cascading churn | **81.1% reshuffled** (472 / 582)<br>❌ Cascading churn | **0.0% reshuffled (0 / 590)**<br>✅ Zero unnecessary churn |
34+
| **Stateless Reshuffle on Node Drop**<br>*($N=7 \to N=6$, no active stickiness history)* | **82.4% reshuffled** (492 / 597)<br>❌ Cascading churn | **81.1% reshuffled** (472 / 582)<br>❌ Intrinsic grid shift | **0.0% reshuffled (0 / 590)**<br>✅ Intrinsic monotonicity |
35+
| **Stateful Reshuffle on Node Drop**<br>*($N=7 \to N=6$, with active listener stickiness)* | **82.4% reshuffled**<br>❌ Quota boundary drops node | **0.0% reshuffled (0 / 590)**<br>✅ Mitigated by Layer 1 stickiness | **0.0% reshuffled (0 / 590)**<br>✅ Native without state |
3536
| **Even Order Performance ($N=6$, Euler Order)**<br>*(600 clients across 6 relays)* | **300:300 (50.0% peak share)**<br>❌ Euler modulo collapse | 93 ~ 106 (Peak: 17.7%)<br>✅ Handled by fallback | 82 ~ 110 (Peak: 18.3%)<br>✅ Native uniform spread |
3637
| **Microbenchmark Execution Speed ($K=10$)** | **291 ns/op** | 291 ns/op | 1,106 ns/op |
37-
| **Code Footprint & Mathematical Complexity** | High (coprime search, GCD, grid mapping) | High (dual targets, cross-distance bonus) | **Low (single hash & sort)** |
38+
| **Code Footprint & Mathematical Complexity** | High (coprime search, GCD, grid mapping) | High (dual targets, cross-distance bonus, stickiness rules) | **Low (single hash & sort)** |
3839

3940
---
4041

41-
## 3. Comparative Trade-offs
42+
## 3. Comparative Trade-offs & Architectural Assessment
4243

43-
### A. Stability Under Dynamic Topology ($N \to N \pm 1$)
44-
- **MOLS**: Because grid coordinates are computed modulo $N$, adding or removing a single relay shifts the entire coordinate space. Over $80\%$ of unaffected clients change their primary relay, causing widespread connection churn.
45-
- **HRW**: Guarantees the **monotonicity property**. When relay $k$ drops, only clients connected to $k$ migrate to their respective second choices. Unaffected clients experience **0% churn**.
44+
### A. Churn Storm Mitigation: Intrinsic Monotonicity vs. Stateful Stickiness
45+
- **MOLS**: Without stateful connection memory, MOLS intrinsically reshuffles $\approx 81\%$ of traffic upon pool size changes. With resilient active stickiness, re-routed traffic drops to 0.0% for existing connections, but newly joining clients or re-dialing clients will still compute disjoint grid placements.
46+
- **HRW**: Achieves 0.0% churn **intrinsically and statelessly**. Even without passing `ActiveRelayURLs`, the mathematical mapping guarantees minimal disruption ($1/N$).
4647

4748
### B. Gossip Discovery & Eventual Consistency
4849
- **MOLS**: Requires all participants to share an identical view of $N$ and relay sorting order. If client A discovers 10 relays and client B discovers 9 relays, their coordinate frames diverge completely.

0 commit comments

Comments
 (0)