Skip to main content

Microservices - Client side load balancing with Ribbon


In my previous post I introduced Feign REST client with hard coded (or single) URL. We can improve it using Ribbon.
Ribbon is a client side load balancer which not only provides load balancing feature but also support caching, fault tolerance.

Source code can be found at github.

Add Ribbon library


Update properties

Update cart-service.yml
    listOfServers: localhost:8010,localhost:8011

Update Fiegn Client

@FeignClient(name = "catalog-service")
@RibbonClient(name = "catalog-service")
public interface CatalogServiceFeign

Restart the cart service and test the application. Remember to push the configuration changes to github.