Module: OMQ::Routing::RoundRobin
Overview
Mixin for routing strategies that load-balance via work-stealing.
One shared bounded send queue per socket (‘send_hwm` enforced at the socket level, not per peer). Each connected peer gets its own send pump fiber that races to drain the shared queue. Slow peers’ pumps naturally block on their own TCP flush; fast peers’ pumps keep dequeuing. The result is work-stealing load balancing, which is strictly better than libzmq’s strict per-pipe round-robin for PUSH-style patterns.
See DESIGN.md “Per-socket HWM (not per-connection)” for the full reasoning.
Including classes must call ‘init_round_robin(engine)` from their #initialize.
Constant Summary collapse
- BATCH_MSG_CAP =
256- BATCH_BYTE_CAP =
512 * 1024
Instance Method Summary collapse
-
#send_queues_drained? ⇒ Boolean
True when the shared send queue is empty and no pump fiber is mid-write with a dequeued batch.
Instance Method Details
#send_queues_drained? ⇒ Boolean
Returns true when the shared send queue is empty and no pump fiber is mid-write with a dequeued batch.
28 29 30 |
# File 'lib/omq/routing/round_robin.rb', line 28 def send_queues_drained? @send_queue.empty? && @in_flight == 0 end |