Search code examples
cluster-computingmicroservices

Clustering Microservices Components


I have a Microservice that is realised as a Play framework based HTTP service. We now want to add fault tolerance to this service by having another instance that picks up the requests when one instance goes down. Now I understand that Microservices are not designed from the ground up to be clustered as they are purely stateless, self sustaining components that are meant to simply run.

Are there ways wherein I could add failover support? I'm thinking of some external component that checks for the status of the service and reacts upon failures by starting another instance on some other host. Any suggestions?


Solution

  • Generally, there is a discovery service where the services can register theirselves. If a service needs to communicate with another service, it requests instances of these service at the discovery service and most of the time there is client-side load balancing as well.

    I've also used Hystrix to wrap HTTP calls to handle failure.

    I'm not familiar with building microservices with the Play framework, but when using Spring I've used:

    • Netflix Eureka - as the discovery service
    • Hystrix - To handle HTTP failures / timeouts when services go down
    • Ribbon - Client side load-balancing

    A blog series that provides an example using the full stack is this one. However, it is using Spring but I guess it can be helpful either way.