rajvarun77 opened a new pull request, #3502: URL: https://github.com/apache/brpc/pull/3502
# What & Why Classic consistent hashing has no relief valve for hot keys: one server saturates while its ring neighbors sit idle. This PR adds `c_murmurhash_bl`, an implementation of ["Consistent Hashing with Bounded Loads"](https://arxiv.org/abs/1608.01350) (Mirrokni et al., CACM 2017) on the existing murmurhash ring, so hot-key overflow spills to deterministic ring successors instead of overloading a single server. # Usage ``` options.load_balancer_type = "c_murmurhash_bl"; // default factor from -chash_bounded_load_factor (1.25, must be > 1) options.load_balancer_type = "c_murmurhash_bl:load_factor=1.5"; // per-channel override; replicas= also supported ``` # Design - Subclass of `ConsistentHashingLoadBalancer`; only `SelectServer` and load accounting differ, ring construction is shared. - Per-server capacity = `ceil(load_factor * (total_inflight + 1) / server_count)`; an at-capacity server overflows clockwise to the next server with spare capacity, with first-seen fallback if all are at capacity. - In-flight counters are relaxed atomics shared across both DoublyBufferedData buffers, incremented at selection, decremented exactly once in `Feedback()` (total stays consistent even if the server was removed in between), and resynced on membership change. # Tests & Docs 7 new cases in `test/brpc_ch_bounded_load_balancer_unittest.cpp` (factor/replicas validation, hot-key capping, overflow to ring successor, feedback decrement, removal consistency, no accounting without changable_weights); existing consistent-hashing tests unchanged and passing. Documented in `docs/cn/client.md` and `docs/en/client.md`. cc @chenBright (reviewer of the sibling p2c load balancer, #3367) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
