Module balance
Middleware that allows balancing load among multiple services.
In larger systems, multiple endpoints are often available for a given service. As load increases, you want to ensure that that load is spread evenly across the available services. Otherwise, clients could see spikes in latency if their request goes to a particularly loaded service, even when spare capacity is available to handle that request elsewhere.
This module provides the p2c middleware, which implements the "Power of
Two Random Choices" algorithm. This is a simple but robust technique for
spreading load across services with only inexact load measurements. Use this
if the set of available services is not within your control, and you simply
want to spread load among that set of services.
Examples
#
#
#
Modules
-
error
Error types for the
tower::balancemiddleware. - p2c This module implements the "Power of Two Random Choices" load balancing algorithm.