Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
broker: route request/response via TBON
The ring overlay latency is linearly proportional to the distance betweeen ranks, which can be great in a large instance. Therefore, instead of routing all RPCs that target a specific rank via the ring, use the TBON. If target rank is a descendant of the current broker rank, send it "down" the TBON. Otherwise send it "up". Since all ranks are descendants of rank 0, eventually a route will be found. Routes on the TBON are currently static, so exploit this property to calculate routes in lieu of maintaining dynamic routing tables. Tricky: RPCs accumulate a "route stack" as the request travels towards its destination. This stack is unwound to direct the response along the same path in reverse. A special direction-sensitive property of the zeromq DEALER-ROUTER sockets used in the TBON (specifically the ROUTER socket) is that it pushes peer socket's identity onto route stack when a message is travelling "up" towards the root, and pops an identity off the stack when a message is travelling "down" away from the root. The popped identity select the peer branch. See also: http://api.zeromq.org/4-1:zmq-socket When responses are routed "up", the ROUTER behavior must be subverted on the receiving end by popping two frames off of the stack and discarding. When requests are routed "down", the ROUTER behavior must be subverted on the sending end by pushing the identity of the sender, followed by the identity of the peer we want to route to onto the stack.
- Loading branch information