Package io.vertx.core.net.endpoint
Interface LoadBalancer
-
@Unstable public interface LoadBalancerA load balancer.A load balancer is stateless besides the configuration part. Effective load balancing can be achieved with
selector(List)which creates a statefulServerSelectorimplementing the load balancing algorithm.- Author:
- Julien Viet
-
-
Field Summary
Fields Modifier and Type Field Description static LoadBalancerCONSISTENT_HASHINGConsistent hashing load balancer with 4 virtual servers, falling back to a random load balancer.static LoadBalancerLEAST_REQUESTSLeast requests load balancer.static LoadBalancerPOWER_OF_TWO_CHOICESPower of two choices load balancer.static LoadBalancerRANDOMRandom load balancer.static LoadBalancerROUND_ROBINSimple round-robin load balancer.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static LoadBalancerconsistentHashing(int numberOfVirtualServers, LoadBalancer fallback)Sticky load balancer that uses consistent hashing based on a client provided routing key, defaulting to thefallbackload balancer when no routing key is provided.default InteractionMetrics<?>newMetrics()ServerSelectorselector(List<? extends ServerEndpoint> listOfServers)Create a stateful endpoint selector.
-
-
-
Field Detail
-
ROUND_ROBIN
static final LoadBalancer ROUND_ROBIN
Simple round-robin load balancer.
-
LEAST_REQUESTS
static final LoadBalancer LEAST_REQUESTS
Least requests load balancer.
-
RANDOM
static final LoadBalancer RANDOM
Random load balancer.
-
POWER_OF_TWO_CHOICES
static final LoadBalancer POWER_OF_TWO_CHOICES
Power of two choices load balancer.
-
CONSISTENT_HASHING
static final LoadBalancer CONSISTENT_HASHING
Consistent hashing load balancer with 4 virtual servers, falling back to a random load balancer.
-
-
Method Detail
-
newMetrics
default InteractionMetrics<?> newMetrics()
- Returns:
- a new interaction metrics instance
-
consistentHashing
static LoadBalancer consistentHashing(int numberOfVirtualServers, LoadBalancer fallback)
Sticky load balancer that uses consistent hashing based on a client provided routing key, defaulting to thefallbackload balancer when no routing key is provided.- Parameters:
numberOfVirtualServers- the number of virtual serversfallback- the fallback load balancer for non-sticky requests- Returns:
- the load balancer
-
selector
ServerSelector selector(List<? extends ServerEndpoint> listOfServers)
Create a stateful endpoint selector.- Parameters:
listOfServers- the list of servers- Returns:
- the selector
-
-