Skip to content

C++: Support local DC detect based on smallest RTT #252

@Gazizonoki

Description

@Gazizonoki

In YDB, request balancing is handled by the client - the server provides a list of nodes in the cluster, and the SDK distributes the load among them.

The C++ SDK implements 2 balancing policies:

  1. UseAllNodes. All nodes are used uniformly
  2. UsePreferableLocation. Nodes from a user-specified data center are used. If no live nodes remain in the required data center, all nodes in the cluster are used.

A special case of UsePreferableLocation is the PreferLocalDC mode, when no location is specified. In this case, the nearest data center is considered the preferred one. Currently, this mechanism only works in an internal environment - when each node knows which data center it is in, and the balancer sends requests to all data centers during the first connection and returns the fastest response - which is considered to be the local one.

If a user is not in an internal environment, this will not work. However, users still want to use PreferLocalDC to reduce latency. For this purpose, it is proposed to determine the nearest data center using TCP pings. The data center with the smallest RTT will be considered local.

As part of this task, we need to:

  1. Implement a new balancing policy
  2. Write tests for it

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions