Feature #74677
closedrgw/multisite: Improve load distribution when zone endpoints use DNS service discovery
0%
Description
I was torn between whether to open this as an "enhancement" or "feature" but the latter seemed slightly more appropriate for this item.
Please feel free to suggest otherwise.
Motivation / Summary¶
In RGW multisite, a zone's "endpoints" define where peers should send multisite sync (metadata + data) traffic. Today, operators can configure a zone's endpoints either:- by listing every RGW instance explicitly, or
- by pointing to a load balancer; i.e., single endpoint -> rgw instances are hidden behind, or
- point to a DNS name; i.e., service discovery / round-robin DNS.
The first two options work fine. The third option looks like it should work, but in practice often leads to sticky connections and traffic hotspots because a single FQDN entry typically resolves to only one address per long-lived connection and does not automatically spread traffic across all A/AAAA records over time.
This feature request is to make DNS-based endpoints behave like a true "set of backends" for multisite sync, so operators can use service discovery patterns (round-robin DNS, headless service, etc.) without creating hotspots or constantly updating zone/zonegroup endpoint lists.
Background: Endpoint configuration patterns¶
When defining a zonegroup, each zone has an "endpoints" list. Common configurations include:
Use Case 1: Listing individual RGW instances (static list)¶
Example: a zone with 10 RGW instances across 5 nodes (each node hosts 2 RGWs). The zone’s endpoints are configured explicitly:
$ radosgw-admin zonegroup get
...
"zones": [
{
"id": "...",
"name": "zone-A",
"endpoints": [
"http://10.10.10.10:8888",
"http://10.10.10.10:8889",
...
"http://10.10.10.14:8888",
"http://10.10.10.14:8889"
]
}
]
...
Pros:
- RGW can round-robin across the configured list.
- Predictable and avoids DNS caching issues.
- Operationally heavy at scale: large lists, harder to keep correct.
- Requires a period update/commit whenever instances move, scale, or are replaced.
- In dynamic environments (containers/K8s, autoscaling, node replacement), IPs/ports are not stable enough to keep this list accurate.
Use Case 2: Single endpoint behind a load balancer¶
Example:
"endpoints": [ "https://zone-A.example.com" ]Pros:
- Load balancer handles distribution and health checks.
- Simplifies the zone endpoint list (stable, small).
- Requires additional infrastructure (L4/L7 LB), configuration, and operational ownership.
- Can be undesirable for inter-site replication traffic (extra hop, bandwidth concentration, MTU/TLS termination considerations, etc.).
- Some deployments explicitly prefer avoiding dedicated LBs for sync traffic and rely on DNS/service-discovery instead.
Use Case 3: DNS endpoint (service discovery / round-robin DNS)¶
This is the motivating use case.
Option A: multiple ports (matching multiple RGWs per node):
"endpoints": [ "http://zone-A.example.com:8888", "http://zone-A.example.com:8889" ]
Option B: single port/FQDN (LB-like, but implemented as DNS RR or a DNS-backed service):
"endpoints": [ "http://zone-A.example.com" ]
In this model, "zone-A.example.com" resolves to multiple A/AAAA records (e.g., the 5 RGW nodes, or VIPs in front of them), and the DNS answer may change over time as instances are added/removed/replaced.
Pros:- Matches common service discovery patterns and dynamic infrastructure.
- Allows scaling / failover by updating DNS instead of pushing new periods everywhere.
- Even if DNS returns multiple addresses, an RGW peer effectively uses only one address per long-lived connection, which can defeat the user's expectation of load distribution.
Drilling down on Use Case 3 (the problem)¶
In multisite, each RGW in zone-B sends sync traffic to zone-A using the zone-A endpoint entries.
When the endpoint is a single DNS name (e.g. http://zone-A.example.com), the peer (zone-B) does not automatically spread traffic over all IPs that the name can resolve to. Instead:
- One resolution → one chosen IP (from the returned set).
- A long-lived HTTP connection (keep-alive) is established and reused for many sync requests.
- As a result, each zone-B RGW instance tends to become "sticky" to a subset of zone-A backends (often just one), even though zone-A has many RGW instances available.
- A few RGWs (or a few RGW nodes) in zone-A get the majority of the incoming sync traffic.
- The remaining RGWs in zone-A stay underutilized.
- Throughput becomes bounded by the overloaded subset rather than the whole zone capacity.
Why this happens (implementation details)¶
RGW uses libcurl for inter-zone HTTP communication.
libcurl resolves a hostname to an address and maintains DNS results in its in-memory cache, and HTTP keep-alive encourages reusing the same established TCP connection for multiple requests.
Important implications for this use case:- DNS TTL is not necessarily honored in the way operators expect.
- Even if DNS answers rotate, a long-lived connection will continue to target the originally selected backend until that connection is closed/recreated.
- RGW’s existing endpoint round-robin logic operates at the "configured endpoint list entry" level; if there is only one endpoint string, RGW has nothing to rotate between—even if that hostname resolves to multiple IPs.
Impact / Symptoms¶
In real deployments this shows up as:- uneven CPU/network utilization across zone-A RGW instances
- increased replication lag (data sync and/or metadata sync), because one or a few target RGWs become the bottleneck
- reduced resiliency: if the chosen backend becomes unhealthy, the client can keep retrying the same backend for longer than expected instead of naturally shifting to other healthy addresses
Expected behavior / Desired enhancement¶
When a zone endpoint is configured as a DNS name that resolves to multiple addresses, RGW should be able to treat that endpoint as a pool of backends for multisite sync traffic.
At a high level, desirable behavior would be:- resolve the hostname to all A/AAAA records (or at least iterate through them over time)
- distribute requests/connections across the full set of resolved addresses (similar to how we distribute across an explicit endpoint list)
- refresh the DNS resolution periodically and/or on failures, so backend membership changes can be picked up without rewriting zone/zonegroup configs
Why this matters (why not just “use a load balancer”)¶
Requiring an external load balancer for multisite sync traffic is not always acceptable or practical:- adds extra infrastructure and potential bottlenecks
- some environments already rely on DNS-based service discovery for internal services
- dynamic deployments (K8s/headless service, autoscaling groups) can update DNS membership far more easily than pushing frequent multisite period updates
Workarounds today¶
Current workarounds include:- enumerate every RGW instance explicitly (Use Case 1), and update the period whenever membership changes
- deploy a load balancer/ingress in front of the sync RGWs (Use Case 2)
- create multiple stable DNS names (one per RGW host/VIP) and list them explicitly (turning Use Case 3 back into Use Case 1)
- this works, but defeats the purpose of service discovery being the source of truth
Proposed Solutions¶
Below are the main approaches we considered (or experimented with) to make a single DNS endpoint behave more like a “pool” of backends for multisite sync traffic, along with why some of them do not fully solve the problem.
Tune libcurl behavior to reduce “sticky” long-lived connections¶
One idea is to rely on libcurl knobs to force more frequent re-resolution and/or avoid long-lived reuse of a single TCP/TLS connection when the configured endpoint list contains only a single hostname.
Candidate knobs / behaviors include:- Reduce/disable libcurl DNS caching (e.g., very small DNS cache timeout).
- Force new connections more frequently (avoid keep-alive reuse) using options such as "fresh connect" / "forbid reuse", or by periodically tearing down curl handles / connection caches.
- In general, bias toward re-connecting so that each new connection has a chance to pick a different DNS answer.
- It is at best an indirect fix: even if we reconnect frequently, there is no guarantee we will connect to a different backend (depending on resolver behavior, caching layers, and DNS answer ordering).
- Disabling or heavily limiting connection reuse is usually a significant performance regression for multisite sync: ** additional TCP handshakes ** additional TLS handshakes (for HTTPS) ** higher CPU cost and latency per request ** potentially lower overall throughput and worse replication lag under load
- It can increase churn (many short-lived connections) and push cost/complexity to both the sender and receiver, which is undesirable at scale.
In short: these settings can reduce stickiness in some cases, but they are not a robust or efficient way to turn a single DNS name into an even traffic distribution mechanism.
Resolve the DNS endpoint to IPs in RGW and use the IPs directly¶
Another approach is to have RGW periodically resolve a hostname endpoint into its set of A/AAAA records, then treat those IPs as the actual targets (similar to “expanding” a DNS endpoint into an explicit endpoint list).
This can work reasonably for HTTP:- The sender could build URLs like http://10.10.10.10:8888, http://10.10.10.11:8888, etc.
- Then existing endpoint round-robin logic would naturally spread traffic.
- In HTTPS, certificates are typically issued for the hostname (e.g., site-A.abc.com), not for the backend IPs.
- If we replace https://site-A.abc.com with https://10.10.10.10, TLS verification will fail due to hostname mismatch (and potentially SNI mismatch).
- Disabling certificate verification is not acceptable for production multisite deployments.
So while “expand DNS into IP endpoints” is conceptually simple, it is not a general solution for HTTPS-based multisite sync.
Use libcurl's "connect_to" feature to steer connections while preserving HTTPS hostname semantics (preferred / WIP)¶
libcurl provides a "connect to" capability (CURLOPT_CONNECT_TO) that can direct a request for HOST:PORT to instead connect to a specified CONNECT-TO-HOST:CONNECT-TO-PORT.
Key property (and why it fits this use case):- "connect_to" affects only the network connection target.
- It does NOT change the hostname/port used at the TLS layer (SNI, certificate verification) or at the application protocol layer (e.g., HTTP Host header).
- This means we can keep the URL as https://site-A.abc.com (so cert verification and SNI remain correct) while still connecting to a selected backend IP for load distribution.
- Keep the configured endpoint as a stable DNS name (e.g., https://site-A.abc.com or https://site-A.abc.com:8888).
- Resolve site-A.abc.com into its current set of A/AAAA records.
- Choose one backend IP per connection attempt (round-robin, random, or other policy).
- Program libcurl with a connect_to mapping such as:
"site-A.abc.com:443:10.10.10.10:443"
so that curl connects to 10.10.10.10 but still behaves as if it is talking to site-A.abc.com from a TLS/HTTP perspective.
- On failures/timeouts, retry with the next IP (and optionally trigger a re-resolve).
We are currently working on this solution and will reference the draft PR here.
We can discuss other/general workarounds/solutions/ideas at this tracker and if it's particular to the proposed solution we can do so in the pro PR.
Files
OO Updated by Oguzhan Ozmen 10 months ago
https://github.com/ceph/ceph/pull/67141 is the draft PR that implements the proposed solution described at https://tracker.ceph.com/issues/74677#Use-libcurls-connect_to-feature-to-steer-connections-while-preserving-HTTPS-hostname-semantics-preferred-WIP.
OO Updated by Oguzhan Ozmen 10 months ago
- File clipboard-202602041355-xsvcb.png clipboard-202602041355-xsvcb.png added
- File clipboard-202602041406-rhq12.png clipboard-202602041406-rhq12.png added
- Pull request ID set to 67141
Below summarizes the initial functional testing of the proposed solution found in [WIP] rgw/multisite: Balance sync traffic across DNS-resolved backends using CURLOPT_CONNECT_TO#67141
Multisite Cluster Setup¶
- 2 zones/clusters: one is used as primary/master getting the client traffic and the other as stand-by/secondary which doesn't receive any client traffic but pulls/replicates the data from the master zone.
- Each zone has 5 RGW nodes and each node has 3 instances:
- All together 5x3=15 instances per zone.
- Given an RGW node:
- 2 instances are used to serve client traffic: e.g., named as dev.1 and dev.2
- 1 instance is used to serve replication traffic: e.g., named as rep.1
- Zonegroup is configured to use a single DNS service discovery endpoint for both zones:
- primary zone defines its endpoint like "master.abc.com"
- secondary zone defines its endpoint like "secondary.abc.com"
To visualize this setup at a high level:
[ DNS SERVICE DISCOVERY ENDPOINTS ]
( [master,secondary].abc.com )
|
_________________________|_________________________
| |
▼ ▼
[ PRIMARY ZONE ] [ SECONDARY ZONE ]
(Active Traffic) (Standby / Pull Only)
| |
| +---------------------------------------+ | (No Client Traffic)
| | RGW NODE 1 | | |
| | [well-known port: port-W] | | |
| | | | | |
| V V | | |
| ___________________________________ | | X
+-- | | port-1 | port-2 | port-3 | | | |
| | | | | | | | | | [ RGW NODE 1 ]
| | V | V | V | | | | dev.1 (Pull) |
| | dev.1 | dev.2 | rep.1 | | | | dev.2 (Pull) |
| | (Client) | (Client) | (Sync/Rep) | | | | rep.1 (Pull) |
| |__________|__________|_____________| | | [______________]
+---------------------------------------+ | :
| | :
+---------------------------------------+ | :
| RGW NODE 2 | | [ RGW NODE 5 ]
| (Same 3-instance config) | | | dev.1 (Pull) |
+---------------------------------------+ | | dev.2 (Pull) |
: | | rep.1 (Pull) |
: | [______________]
+---------------------------------------+ |
| RGW NODE 5 | |
| (Same 3-instance config) | |
+---------------------------------------+ |
| |
| REPLICATION |
|<<<<<<<<<<<<<<<<<<<<<<<<<<<|
(Secondary pulling
data from Master)
So, zonegroup cfg for such a cluster looks like
$ radosgw-admin zonegroup get
{
"api_name": "dev-zonegroup",
"is_master": true,
"endpoints": [
"http://master.abc.com:<portW>",
],
...
"zones": [
{
"name": "zone-master",
"endpoints": [
"http://master.abc.com:<port3>"
],
...
},
{
"name": "zone-secondary",
"endpoints": [
"http://secondary.abc.com:<port3>"
],
...
}
]
...
That's,
- when clients discover the S3 service (master rgws) and
- when each zone discovers the other for replication purpose
DNS service discovery endpoints are used with no dedicated load-balancer.
Baseline Testing¶
Client workload is initiated to the master cluster as follows:- PUT only wkld for 15 mins via 15 distinct users; each user creating 4 buckets and PUTing objects of 4 different size
- In the end of 15 mins, users delete all the objects they've uploaded
- The total IOPS across 5x2 rgw instances at the master cluster
- The replication user's total IOPS seen by the 5 rep.1 instances at the master cluster
- The distribution of the replication traffic at the master site across 5 rep.1 instances
- The CPU usage of the master RGW node which received the most replication traffic (i.e., node-111)

Same Wkld with DNS-awareness Enhancement¶
After enabling the proposed enhancement on both clusters:
ceph config set client.rgw rgw_resolve_endpoints_into_all_addresses true

Comparing Baseline with the DNS-awareness Enhancement¶
- Better load-balancing at the master site:
- Baseline: Only 3 of the 5 rep.1 instances were involved in handling the replication traffic. This is exactly what we observe in our production clusters as each rgw instance picks just 1 IP given a single endpoint so that multiple instances can pick the same IP and stick with it until they are restarted - which results in such imbalances.
- With DNS-awareness: all 5 instances joined in the workforce.
- Furthermore, in baseline case, it's not just 3 of the 5 rep.1s were utilized, there was still skewness across these 3; e.g., while node-111 was handling 38% of the work, node-92 was handling 29%. It wasn't a nice 33% distribution. With the dns-awareness, all 5 instances were now getting 20% of the share equally.
- Better load-balancing is reflected in CPU usage as well:
- While node-111's rep.1 instance was showing 300% CPU usage in baseline case, with the enhancement, it dropped to 180% - which makes sense as node-111's replication traffic share dropped from 38% to 20% (proportional drop in cpu usage).
- The Final observation which shows the better load-balancing will help the replication lag:
- Baseline: PUT+DELETE client traffic was ended around 12:47 but the master cluster was still receiving replication traffic till 12:50 - a 3 min tail to catch up.
- DNS-awareness: this catch-up tail is just a few seconds: while client wkld ended around 16:35 so did replication traffic received by the master.
OO Updated by Oguzhan Ozmen 8 months ago
- Status changed from New to Fix Under Review
UB Updated by Upkeep Bot 6 months ago
- Status changed from Fix Under Review to Resolved
- Merge Commit set to 7d3cb2c34dbd3292ffd34000e1d81f1196504b07
- Fixed In set to v21.3.0-215-g7d3cb2c34d
- Upkeep Timestamp set to 2026-06-17T13:54:00+00:00
CB Updated by Casey Bodley 6 months ago
- Status changed from Resolved to Pending Backport
- Backport set to umbrella
UB Updated by Upkeep Bot 6 months ago
- Copied to Backport #77473: umbrella: rgw/multisite: Improve load distribution when zone endpoints use DNS service discovery added
UB Updated by Upkeep Bot 6 months ago
- Tags (freeform) set to backport_processed
OO Updated by Oguzhan Ozmen 3 months ago
- Status changed from Pending Backport to Resolved
Backported to umbrella.
UB Updated by Upkeep Bot 3 months ago
- Tags (freeform) deleted (
backport_processed) - Upkeep Timestamp changed from 2026-06-17T13:54:00+00:00 to 2026-08-28T01:41:32+00:00