Skip to content

Random Load Balancing#

The random load balancing is a straightforward service instance selection solution that picks a random instance every time.

Dependency#

First, you need to add the random load-balancer to your project:

<dependency>
    <groupId>io.smallrye.stork</groupId>
    <artifactId>stork-load-balancer-random</artifactId>
    <version>1.3.2</version>
</dependency>

Configuration#

For each service expected to use a random service selection, configure the load-balancer to be random:

stork.my-service.service-discovery.type=...
stork.my-service.service-discovery...=...
stork.my-service.load-balancer.type=random
quarkus.stork.my-service.service-discovery.type=...
quarkus.stork.my-service.service-discovery...=...
quarkus.stork.my-service.load-balancer.type=random

Supported attributes are the following:

Attribute Mandatory Default Value Description
use-secure-random No false Whether the load balancer should use a SecureRandom instead of a Random (default). Check this page to understand the difference