Package io.vertx.core.net.endpoint

## Interface LoadBalancer

-     @Unstable
      public interface LoadBalancer

  A load balancer.

  A load balancer is stateless besides the configuration part. Effective load balancing can be achieved with `selector(List)` which creates a stateful `ServerSelector` implementing the load balancing algorithm.

  Author:
    Julien Viet

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static LoadBalancer` | `CONSISTENT_HASHING` | Consistent hashing load balancer with 4 virtual servers, falling back to a random load balancer.
    `static LoadBalancer` | `LEAST_REQUESTS` | Least requests load balancer.
    `static LoadBalancer` | `POWER_OF_TWO_CHOICES` | Power of two choices load balancer.
    `static LoadBalancer` | `RANDOM` | Random load balancer.
    `static LoadBalancer` | `ROUND_ROBIN` | Simple round-robin load balancer.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static LoadBalancer` | `consistentHashing​(int numberOfVirtualServers, LoadBalancer fallback)` | Sticky load balancer that uses consistent hashing based on a client provided routing key, defaulting to the `fallback` load balancer when no routing key is provided.
    `default InteractionMetrics<?>` | `newMetrics()` |
    `ServerSelector` | `selector​(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 the `fallback` load balancer when no routing key is provided.
      Parameters:
        `numberOfVirtualServers` - the number of virtual servers
        `fallback` - 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