ydb-platform / ydb-platform/ydb-cpp-sdk

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

Open
#252 1 comment 0 reactions 1 assignee View on GitHub

@Ilya-Repin is already working on this.

Since Sep 1, 2025.

  • #564 by @Ilya-Repin — open
enhancement student-projects
Dominant language
C++
Stars
19
Forks
31
Avg merge
2d 5h
Merged PRs (30d)
10

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.