Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: add a mechanism for various endpoint selection mode
Current etcd client library chooses a default destination node from every member of a cluster in a random manner. However, requests of write and read (for consistent results) need to be forwarded to the leader node as the nature of Raft algorithm. If the chosen node is a follower, additional network traffic will be caused by the forwarding from follower to leader. Mainly for reducing the forward traffic, this commit adds a new mechanism for various endpoint selection mode to the client library which can be configured with client.Config.SelectionMode. Currently, three modes are provided: - EndpointSelectionDefault: default, same to existing behavior (pick a node in a random manner) - EndpointSelectionPrioritizeLeader: prioritize leader, for the above purpose - EndpointSelectionPreference: with this mode, client program selects a prioritized endpoint manually. This option is targetting a new local (not quorum) and consistent read request which will be implemented in the future. I evaluated the effectiveness of the EndpointSelectionPrioritizeLeader with 4 t1.micro instances of AWS (3 nodes for etcd cluster and 1 node for etcd client). Client executes this simple benchmark (https://github.com/mitake/etcd-things/tree/master/prioritize-leader-bench), just writes 10000 keys. When PrioritizeLeader is false, the benchmark needed 1 min and 32.102 sec to finish. When it is true, the benchmark needed 1 min 4.760 sec.
- Loading branch information