Hystrix – a simple use case

Hystrix is a fault tolerance library that is very useful for managing failures in a distributed environment like microservices. Suppose we have a service A dependent on service B, which is in turn dependent on service C.

A -> B -> C

Let’s say a call is made from A to B. To serve this request, B needs to call C but there’s a communication failure between them. If the call from B to C is wrapped in Hystrix mechanism, we prevent the failure being propagated to A. Because B couldn’t fetch the actual information from C, Hystrix gives us the option of declaring a fallback value to be used in this case, if feasible.

[Read More]

Step by step guide to set up a service discovery environment

In a microservices environment we can run multiple instances of a service for resilience and scalability. In a cloud environment these instances can go up and down arbitrarily. So we need some kind of service discovery mechanism to keep track of running instances. When a service A needs to call a service B, it asks for the address of any running instance of service B from the service discovery. The service discovery can also load balance the incoming requests. In this post I demonstrate how to setup a service discovery environment with Netflix Eureka. When ever a service instance spins up, it registers itself with Eureka and sends regular heartbeats to confirm its availability.

[Read More]

How to set up a local spring cloud config server

From the official documentation,

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments.

Steps to configure config server

a. Create a new Gradle project for the config server. In https://start.spring.io/, select the starters for config server.

b. In your project, navigate to src/main/resources. Rename the automatically generated application.properties file to bootstrap.yml.

[Read More]