Now that we’ve got circuit breakers in place it’s time to revisit the failover strategies in case a service becomes unresponsive, erroneous or permanently unavailable. This introduces client side load balancing using Netflix Ribbon.

In this activity we change the client code to use Ribbon instead of the JAX-RS. We launch two service instances of the same kind (i.e. Catalog) and terminate one, then verify that Ribbon does failover to the other instance. In a last step we introduce a cache handler that serves cached values if the catalog service becomes permanently unavailable.

step 6.png
Figure 1. Load-balancing and failover

Concepts

  • Load balancing

  • Failover

Tasks

  • Add the ribbon dependencies to your maven pom.xml (everest module)

  • Focus on a single service client, for instance the catalog client

  • Change the service client invocation from JAX-RS to using ribbon instead

  • Launch two services of the same kind (i.e. catalog) and see it failover (to the second instance) and fallback (to cached values if no instance is available)

Outcome

  • The services clients use the ribbon API to invoke on services

  • You can use the web frontend as expected, but if you terminate a dependent service instance, the ribbon based client does failover