Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize selection of orderer nodes with retry #2951

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

andrew-coleman
Copy link
Member

In the Submit() API method, the list of available orderers has been randomized to support improved load balancing.
Retry logic has been added such that if the selected orderer fails to return a success code, then the next orderer in the list is tried. If no orderers succeed, then return an error (containing details from each orderer) to the client.

Resolves #2912

Signed-off-by: andrew-coleman andrew_coleman@uk.ibm.com

@andrew-coleman andrew-coleman requested a review from a team as a code owner September 28, 2021 09:42
@@ -279,31 +280,46 @@ func (gs *Server) Submit(ctx context.Context, request *gp.SubmitRequest) (*gp.Su
return nil, status.Errorf(codes.Unavailable, "no orderer nodes available")
}

orderer := orderers[0] // send to first orderer for now
// randomly shuffle orderers
rand.Shuffle(len(orderers), func(i, j int) { orderers[i], orderers[j] = orderers[j], orderers[i] })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of shuffling perhaps use rand.Perm ? It's shorter syntax and conveys better what we want to accomplish

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's definitely neater. Thanks.

In the Submit() API method, the list of available orderers has been randomized to support improved load balancing.
Retry logic has been added such that if the selected orderer fails to return a success code, then the next orderer in the list is tried. If no orderers succeed, then return an error (containing details from each orderer) to the client.

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
@yacovm yacovm merged commit 3a93662 into hyperledger:main Sep 28, 2021
@andrew-coleman andrew-coleman deleted the orderer_retry branch September 28, 2021 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gateway: randomize selection of orderer nodes with retry
2 participants