{{announcement.body}}
{{announcement.title}}

Microservices Adoption Using Different Patterns

DZone 's Guide to

Microservices Adoption Using Different Patterns

In this article, take a look at microservices adoption using different patterns, such as API gateway, aggregator, circuit breaker, and more.

· Microservices Zone ·
Free Resource

Microservice is an architectural style that made up of smaller (micro) applications that communicate with each other, through open protocols like HTTP. Microservices have a much simpler and direct communication mechanism. Microservices typically deployed Docker platforms in the cloud environment will get maximum benefit.

Microservices architecture's main aim is to break down the applications into smaller applications for maintainability and address the particular functionality. Microservices are scalable, and the maintainability of the application was as typical in monolithic applications. Below are some of the benefits of microservices architecture

  • Time to market for new functionality
  • Seamless integrations
  • Adoption of new technologies
  • Resource (Hardware) utilization effectively
  • Security
  • API based functions for reuse effectively

In monolithic apps, all the functionalities are part of a single application and deployed as a single war/ear file. Earlier days, most of the applications are building by using the MVC design pattern. Microservice architectures create applications that remain maintainable in the long run since the applications are can modify and deploy without impacting other services leads to flexibility. Development and deployment efforts are increasing, and testing should perform for each component or Service in Microservice applications

The biggest challenge is deciding how to partition the exiting system into Microservices. Some strategies have to adapt to decouple the Microservices from existing Monolithic applications. Below are some of the patterns uses in the different domains while decoupling the applications. The patterns are widely used in all domains

  • Decompose by Business Capability
  • Decompose by Sub Domain
  • API Gateway
  • Aggregator
  • Circuit Breaker
  • Distribute Tracing
  • Log Aggregator

Design Pattern

Description

Decompose By Business Capability

Business can be divided into multiple services to serve one business logic

Decompose By Sub Domain

Business capabilities are identified by analyzing the business and do the organizational structure by subdomain model. Identifying different areas of experience and understanding of the business to decompose


When an application is broken into multiple microservice, few concerns need to be addressed like Different consumers might need different formats of the responses from shared Microservices. These type of concerns are taken care of by Decompose pattern

API Gateway

Gateway works as proxy Service to route a request to the concerned Microservices. The API Gateway offloads the authentication /authorization responsibility of the Microservice

Aggregator

Collaborate with the business functionalities in Microservices are very important due to breaking the functionality into several small pieces of code.


Aggregator pattern helps to combine the data from different services and then send the final response to the consumer.

Circuit Breaker 

Microservices face network issues, suppose one Service calls another service to retrieve data. And another service may be down. Here, the first service request keeps going to the down Service


The Circuit Breaker pattern helps to reduce network issue. The consumer invokes the remote Service via Proxy. When several consecutive failures cross a threshold, the circuit breaker trips and set timeout period, all attempts to invoke remote Service will fail immediately

Distribute Tracing 

One Microservice may invoke other services. Each Service handles a request by multiple operations; trace an end-to-end request flow to troubleshoot is not possible To overcome this issue, use Distribute Tracing pattern bypassing one uniquid for all external services and should include that id in all logs.

Log Aggregator

Which helps to aggregate a single logfile from all instances. AWS cloud watch helps to address this type of issue. The same available in significant cloud vendors

Deployment

Deployment of the smaller applications is critical in Microservices applications.

Blue-Green Deployment zone deployments help the zero downtime. It achieves this by running to Identical production machines. Any time one of the environments, the Blue Zone, is live other is in sleep mode.


Code changes can be made in the Green zone and switch the DNS from Blue to Green. All cloud platforms provide supports for the Green and Bule zone deployments

Security

All the APIs are protected from possible attacks by using HTTPS-certificates. Client and Server communications calls are encrypted using transport layer security (TLS).


Use the OAuth2.0 protocol for all microservices for security protocol. OAuth2.0 is an authorization framework that allows users to obtain admittance to a resource from the resource server and achieved using the token mechanism. Use multi-factor authentication when the user comes from the website, and we need to authorize them on the front-end.


Topics:
aggregator, api gateway, circuit breaker, microservices, microservices adoption, monolithic apps

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}