Skip to content

Add ServiceInstanceListSupplier #595

@elandau

Description

@elandau

Would it be possible to add support for more advanced load balancing algorithms other than simple round robin. Specifically, it would be great to see an implementation of Power of Two Choices. There's a great description of the algorithm here, https://www.nginx.com/blog/nginx-power-of-two-choices-load-balancing-algorithm/.

To be able to support such algorithms we'd need to make a slight change to how the load balancer tracks ServiceInstances. Instead of a ServiceInstanceSupplier I'd suggest creating a ServiceInstanceListSupplier (returning Flux<List>). This would allow the load balancer to reactively update its internal state (i.e add or remove ServerInstances from the pool) outside of the load balancer decision. With the current Flux this state could only be maintained as part of the load balancer decision which could be very costly. This approach has the added benefit of not having to create a List for each load balancer decision. The list of ServerInstance would only be updated when there was an actual change to the target cluster.

Looking at the code I was also not able to find any places where Response#onComplete is actually invoked, other than unit tests. This would also need to be fully wired up so that the algorithm can properly track the number of pending requests.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions