- Posted on : September 4, 2018
-
- Industry : Digital and High Technology
- Type: Blog
By : Mohit Kumar Mittal | Senior Architect and Hemen Goswami | Vice President
Introduction
Microservice is an architecture that has been gaining traction in the past few years. MSA (Microservice Architecture) defines an application as a program composed of loosely coupled services. This comes with lots of challenges that we must solve up front. Below are some such common challenges, patterns to solve, and some potential technical solutions.
Challenge #1: Service Discovery and Registry
Microservices is an architecture style for distributed computing. An application is composed of multiple fine grain independent services that communicate over a network. To use a service, the consumer needs to know its specific network location. This is an issue that will grow even more complex if the network location of services keeps changing.
Some examples of consumers of services are external clients like Mobile App, API Gateway and other (Micro) services.
Recommended Solution
System designers should implement a service Registry and a database of all the services network locations. They can register services themselves or by way of a third party to a common registry. Consumers can use this service registry to dynamically discover network locations of services.
Technical Implementation
Netflix Eureka service registry, Kubernetes Service
Challenge #2: Unified Access of Services
In Microservices architecture, there can be multiple services and multiple consumers. Different consumers may require different services—for example, Mobile App may need to display fine grained information, while web-based applications may need to render coarse grained information.
On top of that, services may be using different protocols like JMS or REST etc. In order to simplify services access, there needs to be a unified access mechanism.
Recommended Solution
A potential solution to this concern would be to implement an API gateway as a single-entry point for all services. All the consumers will call API gateway and API gateway should route them to their required services. Additionally, API gateway can provide services like “Aggregation of Services”, “Security”, “Metering” etc.
Technical Implementation
Spring Cloud Zuul, Amazon API Gateway, Apigee
Challenge #3: Authentication and Authorization
Security is a key aspect in Microservices.
Recommended Solution
Implement a common and centralized authentication service. This service will allow all the consumers to get authenticated before seeking a services access. Individual services should be responsible for the authorization of its consumers.
Technical Implementation
oAuth, JWT
Challenge #4: Logging and Debugging
In a Microservices architecture, there can be use cases that span across services. In a scenario in which each service generates its own logs, it would be nightmare for a developer to troubleshoot a bug, as he/she would have to aggregate all the services log and analyze manually
Recommended Solution
One could instead implement a common logging service, wherein each service can use this service to write logs.
Technical Implementation
Elastich Serach, LogsTash, Kibana (ELK)
Challenge #5: Configuration
Configuring services is an added complexity in Microservices. Since each service is independent, it must be configured separately. This will make it difficult to run applications in different environments without making adjustments. Configurations can be anything like DB Credentials, Environment Variables and Network Locations.
Recommended Solution
Implement a common/centralized configuration service. This service can be backed by a common configuration repository so that all services can request this service to read configurations.
Technical Implementation
Spring Cloud Config Server , kubernetes configmap