Skip to content

Commit 80ef796

Browse files
authored
Support load balancing policy at cluster level and RING_HASH config (#1136)
* adopt envoy ring hash lb config * support list of lb policies * fix mm2 hash typo * add least request and rr config * update changelog * support client types * make client type optional
1 parent 8c8fe62 commit 80ef796

File tree

9 files changed

+168
-15
lines changed

9 files changed

+168
-15
lines changed

CHANGELOG.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and what APIs have changed, if applicable.
1414

1515
## [Unreleased]
1616

17+
## [29.84.0] - 2026-02-03
18+
- Add load balancing policies to D2Cluster and LB config for RingHash, LeastRequest, and RoundRobin.
19+
1720
## [29.83.1] - 2026-01-19
1821
- Add open telemetry support for xds client sensor.
1922

@@ -36,10 +39,10 @@ Add clear method to EvictingCircularBuffer that doesnt attempt to drain
3639
- Add Indis based downstream fetcher
3740

3841
## [29.80.2] - 2025-10-15
39-
- Throw when setting xds server address to null while lbWithFacilitiesFactory is null.
42+
- Throw when setting xds server address to null while lbWithFacilitiesFactory is null.
4043

4144
## [29.80.1] - 2025-10-15
42-
- Not to throw for duplicate xDS client start. Throw when setting xds server address to null only for indis-only.
45+
- Not to throw for duplicate xDS client start. Throw when setting xds server address to null only for indis-only.
4346

4447
## [29.80.0] - 2025-10-10
4548
- Update methodLevelProperties in ServiceProperties constructor
@@ -63,10 +66,10 @@ Add clear method to EvictingCircularBuffer that doesnt attempt to drain
6366
- Add D2 service MethodLevelProperties configuration support
6467

6568
## [29.75.4] - 2025-09-10
66-
- Fix notifyOnLastChunk handling for D2URIMap WildcardResourceSubscriber
69+
- Fix notifyOnLastChunk handling for D2URIMap WildcardResourceSubscriber
6770

6871
## [29.75.3] - 2025-09-08
69-
- DataTranslator: support no fieldDiscriminator in Avro union aliases. Deprecate SchemaTranslator for runtime use.
72+
- DataTranslator: support no fieldDiscriminator in Avro union aliases. Deprecate SchemaTranslator for runtime use.
7073

7174
## [29.75.2] - 2025-09-05
7275
- Rename the outlier detection field in the D2 cluster
@@ -111,7 +114,7 @@ Add clear method to EvictingCircularBuffer that doesnt attempt to drain
111114
- log full announcement data at markup. Use samza container name and process user dir for tracking raw d2 client.
112115

113116
## [29.70.0] - 2025-07-15
114-
- Configure xds stream max retry backoff time and xds channel keep alive time
117+
- Configure xds stream max retry backoff time and xds channel keep alive time
115118

116119
## [29.69.10] - 2025-07-08
117120
- Skipping RawD2Client trackig node creation for local execution
@@ -268,7 +271,7 @@ Add clear method to EvictingCircularBuffer that doesnt attempt to drain
268271
- degrade hosts for HTTP/2 stream errors in Degrader and Relative LB.
269272

270273
## [29.55.0] - 2024-05-23
271-
- Allow HttpBridge to return RetriableRequestException for the Netty max active stream error
274+
- Allow HttpBridge to return RetriableRequestException for the Netty max active stream error
272275

273276
## [29.54.0] - 2024-05-08
274277
- Dual read monitors cluster uris similarity
@@ -286,7 +289,7 @@ Add clear method to EvictingCircularBuffer that doesnt attempt to drain
286289
- fix applying client side service config override in INDIS flow
287290

288291
## [29.51.14] - 2024-03-27
289-
- Support translating default values for optional non-record/union fields to Avro (when TRANSLATE_DEFAULT is enabled).
292+
- Support translating default values for optional non-record/union fields to Avro (when TRANSLATE_DEFAULT is enabled).
290293

291294
## [29.51.13] - 2024-03-26
292295
Upgrade the io.envoyproxy.controlplane module to 0.1.35
@@ -496,7 +499,7 @@ adjust dual read monitoring data match logic and log rate limiter
496499

497500
## [29.42.1] - 2023-05-11
498501
- Add support for returning location of schema elements from the PDL schema encoder.
499-
502+
500503
## [29.42.0] - 2023-05-02
501504
- Remove the overriding of content-length for HEADER requests as per HTTP Spec
502505
More details about this issue can be found @ https://jira01.corp.linkedin.com:8443/browse/SI-31814
@@ -588,7 +591,7 @@ adjust dual read monitoring data match logic and log rate limiter
588591
- Add service discovery event emitter to d2 client
589592

590593
## [29.40.0] - 2022-10-13
591-
- Empty commit to bump pegasus minor version
594+
- Empty commit to bump pegasus minor version
592595

593596
## [29.39.6] - 2022-10-06
594597
- Add equals and hashCode methods to `CollectionResult`, `GetResult`, `UpdateResponse` and `UpdateEntityResponse`.
@@ -642,7 +645,7 @@ Added `Request.getResourceMethodIdentifier()`,
642645

643646
## [29.37.18] - 2022-08-29
644647
- Support supplying D2 subsetting peer cluster name at run-time
645-
648+
646649
## [29.37.17] - 2022-08-29
647650
- Add "notify" to reversed word set when generating data template
648651

@@ -684,7 +687,7 @@ Added `Request.getResourceMethodIdentifier()`,
684687
- Add option to skip deprecated field when recursively generate class spec
685688

686689
## [29.37.4] - 2022-07-25
687-
- Serialize ZK data with non-null fields only
690+
- Serialize ZK data with non-null fields only
688691

689692
## [29.37.3] - 2022-07-18
690693
- Add connection warm up support when a failout has been initiated
@@ -699,7 +702,7 @@ Added `Request.getResourceMethodIdentifier()`,
699702
- Package translated legacy PDSC models into `:restli-common` JAR
700703

701704
## [29.36.1] - 2022-06-22
702-
- Fix FailoutClient delegated client's restRequest invocation
705+
- Fix FailoutClient delegated client's restRequest invocation
703706

704707
## [29.36.0] - 2022-06-21
705708
- Add Enum symbols order change as compatible message in checker. This will make equivalent compatibility check to fail and publish the new snapshot files.
@@ -827,7 +830,7 @@ Added `Request.getResourceMethodIdentifier()`,
827830

828831
## [29.22.15] - 2021-11-30
829832
- Add mock response generator factory for BATCH_FINDER methods.
830-
- Deprecate `FileFormatDataSchemaParser#new(String, DataSchemaResolver, DataSchemaParserFactory)`.
833+
- Deprecate `FileFormatDataSchemaParser#new(String, DataSchemaResolver, DataSchemaParserFactory)`.
831834
- Add file existence check before performing compatibility report check during snapshot and restmodel publishing
832835

833836
## [29.22.14] - 2021-11-24
@@ -5945,7 +5948,8 @@ patch operations can re-use these classes for generating patch messages.
59455948

59465949
## [0.14.1]
59475950

5948-
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.83.1...master
5951+
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.84.0...master
5952+
[29.84.0]: https://github.com/linkedin/rest.li/compare/v29.83.1...v29.84.0
59495953
[29.83.1]: https://github.com/linkedin/rest.li/compare/v29.83.0...v29.83.1
59505954
[29.83.0]: https://github.com/linkedin/rest.li/compare/v29.82.0...v29.83.0
59515955
[29.82.0]: https://github.com/linkedin/rest.li/compare/v29.81.2...v29.82.0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* Enum representing different client types that can use a load balancing policy.
5+
*/
6+
enum ClientType {
7+
/**
8+
* D2 client
9+
*/
10+
D2
11+
12+
/**
13+
* Envoy client
14+
*/
15+
ENVOY
16+
17+
/**
18+
* Vanilla gRPC client
19+
*/
20+
GRPC
21+
}

d2-schemas/src/main/pegasus/com/linkedin/d2/D2Cluster.pdl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ record D2Cluster includes D2ChangeTimeStamps {
5454
* Options for configuring the outlier detection. Only used by gRPC clients.
5555
*/
5656
outlierDetectionConfig: optional OutlierDetectionConfig
57+
58+
/**
59+
* The load balancing policies to use for this cluster.
60+
*/
61+
loadBalancingPolicies: optional array[LoadBalancingPolicy]
5762
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* Configuration for Least Request load balancing policy.
5+
* These are ported from the Envoy proto, please refer to the Envoy proto for more details:
6+
* https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-leastrequestlbconfig
7+
*/
8+
record LeastRequestLbConfig {
9+
/**
10+
* The number of random healthy hosts from which the host with the fewest active requests will
11+
* be chosen. Defaults to 2 so that we perform two-choice selection if the field is not set.
12+
* Must be >= 2.
13+
*/
14+
choice_count: optional int
15+
16+
/**
17+
* The following formula is used to calculate the dynamic weights when hosts have different load
18+
* balancing weights:
19+
*
20+
* ``weight = load_balancing_weight / (active_requests + 1)^active_request_bias``
21+
*
22+
* The larger the active request bias is, the more aggressively active requests will lower the
23+
* effective weight when all host weights are not equal.
24+
*
25+
* ``active_request_bias`` must be greater than or equal to 0.0.
26+
*
27+
* When ``active_request_bias == 0.0`` the Least Request Load Balancer doesn't consider the number
28+
* of active requests at the time it picks a host and behaves like the Round Robin Load Balancer.
29+
*
30+
* When ``active_request_bias > 0.0`` the Least Request Load Balancer scales the load balancing
31+
* weight by the number of active requests at the time it does a pick.
32+
*
33+
* This setting only takes effect if all host weights are not equal.
34+
*/
35+
active_request_bias: optional double
36+
37+
/**
38+
* Configuration for slow start mode.
39+
* If this configuration is not set, slow start will not be enabled.
40+
*/
41+
slow_start_config: optional SlowStartProperties
42+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* A load balancing policy configuration with associated client types.
5+
* This provides a mechanism for introducing new load balancing policies
6+
* that are not yet supported by all clients.
7+
*/
8+
record LoadBalancingPolicy {
9+
10+
/**
11+
* The load balancing policy configuration.
12+
*/
13+
config: LoadBalancingPolicyConfig
14+
15+
/**
16+
* The client types that should use this load balancing policy.
17+
*/
18+
clientTypes: optional array[ClientType]
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* Union of all supported load balancing policy configurations.
5+
* This enforces type safety while maintaining extensibility.
6+
* New load balancing policies can be added by extending this union.
7+
*/
8+
typeref LoadBalancingPolicyConfig = union[
9+
RingHashLbConfig,
10+
LeastRequestLbConfig,
11+
RoundRobinLbConfig
12+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* Configuration for Ring Hash load balancing policy.
5+
* These are ported from the Envoy proto, please refer to the Envoy proto for more details:
6+
* https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-ringhashlbconfig
7+
*/
8+
record RingHashLbConfig {
9+
/**
10+
* Minimum hash ring size. The larger the ring is (that is, the more hashes there are for each provided host)
11+
* the better the request distribution will reflect the desired weights.
12+
*/
13+
minimum_ring_size: optional int
14+
15+
/**
16+
* Maximum hash ring size.
17+
*/
18+
maximum_ring_size: optional int
19+
20+
/**
21+
* The hash function used to hash hosts onto the ring.
22+
*/
23+
hash_function: optional enum HashFunction {
24+
/**
25+
* Use `xxHash <https://github.com/Cyan4973/xxHash>`
26+
*/
27+
XX_HASH
28+
29+
/**
30+
* Use `MurmurHash2 <https://sites.google.com/site/murmurhash/>`, this is compatible with
31+
* std:hash<string> in GNU libstdc++ 3.4.20 or above. This is typically the case when compiled
32+
* on Linux and not macOS.
33+
*/
34+
MURMUR_HASH_2
35+
}
36+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace com.linkedin.d2
2+
3+
/**
4+
* Configuration for Round Robin load balancing policy.
5+
* These are ported from the Envoy proto, please refer to the Envoy proto for more details:
6+
* https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-roundrobinlbconfig
7+
*/
8+
record RoundRobinLbConfig {
9+
/**
10+
* Configuration for slow start mode.
11+
* If this configuration is not set, slow start will not be enabled.
12+
*/
13+
slow_start_config: optional SlowStartProperties
14+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=29.83.1
1+
version=29.84.0
22
group=com.linkedin.pegasus
33
org.gradle.configureondemand=true
44
org.gradle.parallel=true

0 commit comments

Comments
 (0)