yandrey321 commented on code in PR #1679:
URL: https://github.com/apache/ratis/pull/1679#discussion_r4464762880
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java:
##########
@@ -171,15 +192,31 @@ public void onCompleted() {
}
}
- CallStreamObserver<AppendEntriesRequestProto> appendEntries(
+ CallStreamObserver<AppendEntriesRequestProto> appendEntries(RaftGroupId
groupId,
StreamObserver<AppendEntriesReplyProto> responseHandler, boolean
isHeartbeat) {
if (isHeartbeat && useSeparateHBChannel) {
return (CallStreamObserver<AppendEntriesRequestProto>)
hbAsyncStub.appendEntries(responseHandler);
} else {
- return (CallStreamObserver<AppendEntriesRequestProto>)
asyncStub.appendEntries(responseHandler);
+ final RaftServerProtocolServiceStub stub =
appendEntriesStubs.get(getAppendEntriesIndex(groupId));
+ return (CallStreamObserver<AppendEntriesRequestProto>)
stub.appendEntries(responseHandler);
}
}
+ /** @return the index of the appendEntries channel for the given group,
always the same one for a group. */
+ int getAppendEntriesIndex(RaftGroupId groupId) {
+ return Math.floorMod(groupId.hashCode(), appendEntriesStubs.size());
Review Comment:
Implemented round-robin.
Benchmark shows that with K = 2, hashing sometimes put both busy groups on
the same connection, and one follower event-loop thread ran at 86–97% while the
other was idle. With round round-robin connection threads have even CPU
consumption.
--
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]