Making Microservices Resilient

Introduction

This is a repository contains instructions for making the [reference applicaiotn] (https://github.com/ibm-cloud-architecture/refarch-cloudnative) Resilient. It will cover topics on making this implementation Highly Available, able to failover, and how to handle disaster recovery.

The Diagram below shows the topology for scaling the solution in Bluemix.

Architecture

Much of the guidance comes from this article.

Adding Load Balancing into the Solution

This section describes how to configure a Global Load Balancer for across 2 Bluemix Instances. We will aim to provide several examples.

Using nginx as a Global Load Balancer

HA and Failover Built into the Bluemix Platform

Container Groups

The Bluemix Platform has built in clustering for Containers.

In our example, we created Container Groups:

  • The Inventry Microservice runs in a Docker Containter.

The command below shows how we create a Container Group, which provides multiple container instances. You can use the tutorial In Step 7, we created the container using a Container Group that creates Docker Cluster to execute.

 cf ic group create -p 8080 -m 512 --min 1 --auto --name micro-inventory-group -e "spring.datasource.url=jdbc:mysql://{ipaddr-db-container}:3306/inventorydb" -e "spring.datasource.username={dbuser}" -e "spring.datasource.password={password}" -n inventoryservice -d mybluemix.net registry.ng.bluemix.net/$(cf ic namespace get)/inventoryservice:cloudnative


cf ic group create -p 8080 -m 512 --min 1 --auto --name micro-socialreview-group -n socialreviewservice -d mybluemix.net registry.ng.bluemix.net/{yournamespace}/socialreviewservice

You can learn about Container Groups here.

It is important that any container that needs to store data, should use volumes as described here.

AutoScale

For our Node.JS based Cloud Foundry Applications, we use AutoScaling built into the platform. Both Services use this.

 cf create-service Auto-Scaling free cloudnative-autoscale

Replicating Databases

How you replicate databases across Cloud Instances is key to providing DR. We have 2 examples for our reference implementation.