Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

MICROSERVICES

Microservice Architecture is a Service Oriented Architecture. In the microservice architecture, there are a large number
of microservices. By combining all the microservices, it constructs a big service. In the microservice architecture, all the services
communicate with each other

The microservice architectural style is an approach to develop a single application as a suite of small services. Each microservice
runs its process and communicates with lightweight mechanisms. These services are built around business capabilities and
independently developed by fully automated deployment machinery.

https://dzone.com/articles/springboot-for-microservices-the-new-age-framework#:~:text=Springboot%20is%20an%20open
%2Dsource,applications%20and%20are%20production%2Dready.

https://examples.javacodegeeks.com/spring-boot-microservices-example/#run

Principles of Microservices

There are the following principles of Microservices:

o Single Responsibility principle

o Modelled around business domain

o Isolate Failure

o Infrastructure automation

o Deploy independently

Advantages of Microservices
o Microservices are self-contained, independent deployment module.

o The cost of scaling is comparatively less than the monolithic architecture.

o Microservices are independently manageable services. It can enable more and more services as the need arises. It
minimizes the impact on existing service.

o It is possible to change or upgrade each service individually rather than upgrading in the entire application.

o Microservices allows us to develop an application which is organic (an application which latterly upgrades by adding
more functions or modules) in nature.

o It enables event streaming technology to enable easy integration in comparison to heavyweight interposes
communication.

o Microservices follows the single responsibility principle.


Disadvantages of Microservices

o Microservices has all the associated complexities of the distributed system.

o There is a higher chance of failure during communication between different services.

o Difficult to manage a large number of services.

o The developer needs to solve the problem, such as network latency and load balancing.

o Complex testing over a distributed environment.

Difference between Microservices Architecture (MSA) and Services-Oriented Architecture (SOA)

Microservice Based Architecture (MSA) Service-Oriented Architecture (SOA)

Microservices uses lightweight protocols such as REST, SOA supports multi-message protocols.


and HTTP, etc.

It focuses on decoupling. It focuses on application service reusability.

It uses a simple messaging system for communication. It uses Enterprise Service Bus (ESB) for communication.

Microservices follows "share as little as possible" architecture SOA follows "share as much as possible architecture" approach.
approach.

Microservices are much better in fault tolerance in comparison SOA is not better in fault tolerance in comparison to MSA.
to SOA.

Each microservice have an independent database. SOA services share the whole data storage.

MSA used modern relational databases. SOA used traditional relational databases.

MSA tries to minimize sharing through bounded context (the SOA enhances component sharing.


coupling of components and its data as a single unit with
minimal dependencies).
It is better suited for the smaller and well portioned, web-based It is better for a large and complex business application environment.
system.

Microservices Monitoring:

There are five principles of monitoring microservices, as follows:

o Monitor container and what's inside them.

o Alert on service performance.

o Monitor services that are elastic and multi-location.

o Monitor APIs.

o Monitor the organizational structure.

These principles allow us to address technological changes associated with the microservices and organizational changes
related to them.

o Hystrix dashboard

o Eureka admin dashboard

o Spring boot admin dashboard

Components of Microservices

There are the following components of microservices:

o Spring Cloud Config Server : 2. Spring Cloud Config Server

o Netflix Eureka Naming Server : Eureka naming server is an application that holds information about all client service
applications. Each microservice registers itself with the Eureka naming server. The naming server registers the client
services with their port numbers and IP addresses. It is also known as Discovery Server.  Eureka naming server comes
with the bundle of Spring Cloud. It runs on the default port 8761. It also comes with a Java-based client component,
the eureka client, which makes interactions with the service much easier.

o Hystrix Server: Hystrix is a library that controls the interaction between microservices to provide latency and fault
tolerance. Additionally, it makes sense to modify the UI to let the user know that something might not have worked
as expected or would take more time. Implementing Fault Tolerance with Hystrix.

o Netflix ZuulAPI Gateway Server: Zuul API Gateway. In this tutorial, we are mainly focused… | by Kasun
Dissanayake | Geek Culture | Medium
o Netflix Ribbon: Load Balancer: Load balancing Spring Boot Microservices using Netflix’s Ribbon -
Studytonight
o Zipkin Distributed Tracing Server: Spring Cloud - Zipkin and Sleuth - HowToDoInJava
Spring Cloud Config Server

Spring Cloud Config Server provides the HTTP resource-based API for external configuration in the distributed system. We can
enable the Spring Cloud Config Server by using the annotation @EnableConfigServer.

Application Port

Spring Cloud Config Server 8888

Netflix Eureka Naming Server 8761

Netflix Zuul API gateway Server 8765

Zipkin distributed Tracing Server 9411

Microservice is the process of implementing Service-oriented Architecture (SOA) by dividing the entire application as a
collection of interconnected services, where each service will serve only one business need.

Scaling: X, y, and Z axis scaling.

Categories of Services

By the name Microservice, we assume that it will be a service that can be consumed over HTTP protocols, however we need to
know what kind of services can be build using this architecture. Following is the list of services that can be implemented using
Microservice architecture.

Platform as a Service [PaaS] − In this service-oriented architecture, the platform is given as a tool which can be customized
according to the business needs. PaaS plays an important role in mobile application development. The greatest example of
PaaS is Google App engine, where Google provides different useful platform to build your application. PaaS originally develops
to provide a built-in architecture or infrastructure to developers. It reduces the higher level programming complexity in
dramatically reduced time. Following is a snapshot of Google provided PaaS.

Software as a Service [SaaS] − Software as a Service is a software licensing business, where the software is centrally hosted and
licensed on a subscription basis. SaaS can be accessed mainly through the browser and it is a very common architecture pattern
in many business verticals such as Human Resource Management (HRM), Enterprise Resource Planning (ERP), Customer
Relationship Management (CRM), etc. Following screenshot shows examples of different SaaS provided by Oracle.

Infrastructure as a Service [IaaS] − Infrastructure plays a good role in IT industries. Using cloud computing, some of the
organizations provide virtual infrastructure as their services. IaaS is very helpful for bringing agility, cost-effectiveness, security,
performance, productivity, etc. in software development. Amazon EC2 and Microsoft Azure are the biggest examples of IaaS.
The following image depicts an example of AWS, where the data center is provided as IaaS.

Data as a Service [DaaS] − Information technology deals with data and some of the top industry leaders believe that data will
be the new sustenance of the society. DaaS is a type of service where data is shared with business conglomerates for research
and analysis. DaaS brings simplicity, agility, and security in the data access layer. Following is an example of Oracle Data cloud,
which can be accessed or licensed for your own business needs.

Back End as a Service [BaaS] − BaaS is also known as MBaaS, which means mobile back-end as a service. In this type of service,
backend of the application will be provided to business units for their own business ventures. All push notifications, social
networking services fall under this type of services. Facebook and Twitter are examples of well-known BaaS service provider.

To prevent the above-mentioned security problems, following are some of the defensive mechanisms used by organizations.

 Deterrent Control − Know you potential threat to reduce cyber-attack.


 Preventive Control − Maintain high level authentication policy to access your cloud.
 Detective Control − Monitor your users and detect any potential risk.
 Corrective Control − Work closely with different teams and fix the issues that arise during the detective control
phase.

Composition patterns:

Aggregator Pattern

Aggregator pattern is the simplest web pattern that can be implemented while developing a microservice. In this composition
pattern, a simple web module will act as a load balancer, which means it will call different services as per requirements.
Following is a diagram depicting a simple microservice web app with aggregator design. As seen in the following image, the
"Aggregator" is responsible for calling different services one by one. If we need to apply any business logic over the results of
the service A, B and C, then we can implement the business logic in the aggregator itself.

An aggregator can be again exposed as another service to the outer world, which can be consumed by others whenever
required. While developing aggregator pattern web service, we need to keep in mind that each of our services A, B and C should
have its own caching layers and it should be full stack in nature.

Proxy Pattern

Proxy microservice pattern is a variation of the aggregator model. In this model we will use proxy module instead of the
aggregation module. Proxy service may call different services individually.

In Proxy pattern, we can build one level of extra security by providing a dump proxy layer. This layer acts similar to the
interface.

Chained Pattern

As the name suggests, this type of composition pattern will follow the chain structure. Here, we will not be using anything in
between the client and service layer. Instead, we will allow the client to communicate directly with the services and all the
services will be chained up in a such a manner that the output of one service will be the input of the next service. Following
image shows a typical chained pattern microservice.

One major drawback of this architecture is, the client will be blocked until the entire process is complete. Thus, it is highly
recommendable to keep the length of the chain as short as possible.

Branch Microservice Pattern


Branch microservice is the extended version of aggregator pattern and chain pattern. In this design pattern, the client can
directly communicate with the service. Also, one service can communicate with more than one services at a time. Following is
the diagrammatic representation of Branch Microservice.

Branch microservice pattern allows the developer to configure service calls dynamically. All service calls will happen in a
concurrent manner, which means service A can call Service B and C simultaneously.

Shared Resource Pattern

Shared resource pattern is actually a conglomerate of all types of patterns mentioned earlier. In this pattern, the client or the
load balancer will directly communicate with each service whenever necessary. This is the most effective designing pattern
followed widely in most organizations. Following is a diagrammatic representation of the Shared Resource design pattern.

Here are the main differences between APIs and microservices:

 An API is a contract that provides guidance for a consumer to use the underlying service.
 A microservice is an architectural design that separates portions of a (usually monolithic) application into
small, self-containing services.

When developing microservices with java, you can use several microservices framework. Some of the frameworks are Spring
Boot, Jersey, Dropwizard, Play Framework, and Restlet.

GOOD Tutor:

https://microservices.io/patterns/deployment/multiple-services-per-host.html

You might also like