Java / Micronaut Interview questions
How do you implement client-side load balancing in Micronaut?
Client-side load balancing in Micronaut happens automatically when a @Client targets a logical service ID instead of a fixed URL, combined with a service discovery source that tells Micronaut which instances currently exist.
@Client("payments-service") public interface PaymentClient { @Get("/health") Mono<String> health(); }
Instead of a hostname, "payments-service" is resolved through whatever discovery mechanism is configured, such as Consul, Eureka, Kubernetes DNS/labels, or a static list defined in application.yml, and Micronaut's LoadBalancer picks an instance per call using a strategy such as round-robin.
Because this resolution happens per request rather than once at startup, the client automatically adapts as instances scale up, scale down, or are marked unhealthy, without the calling code changing at all.
More Related questions...