Web technologies/2014-2015/Laboratory 13.5

What are Microservices?
Microservices is a service-oriented architecture pattern wherein applications are built as a collection of various smallest independent service units. It is a software engineering approach which focuses on decomposing an application into single-function modules with well-defined interfaces. These modules can be independently deployed and operated by small teams who own the entire lifecycle of the service.

The term "micro" refers to the sizing of a microservice which must be manageable by a single development team ( 5 to 10 developers). In this methodology, big applications are divided into smallest independent units.

What is Monolithic Architecture?
In layman terms, you can say that Monolithic architecture is like a big container in which all the software components of an application are clubbed into a single package.

Let's discuss an example of an eCommerce store in context of a Monolithic architecture.

In any e-commerce application, there are some standard features like Search, Review & Ratings, and Payments. These features are accessible to customers using their browser or apps. When the developer of the eCommerce site deploys the application, it is a single Monolithic unit. The code for different features like Search, Review & Ratings, and Payments are on the same server. To scale the application, you need to run multiple instances(servers) of these applications.



What is Microservice Architecture?
Microservice Architecture is an architectural development style which allows building an application as a collection of small autonomous services developed for a business domain.

Let's take an example of e-commerce application developed with microservice architecture. In this example, each microservice is focused on single business capability. Search, Rating & Review and Payment each have their instance (server) and communicate with each other.

In this Monolithic Architecture, all the components coalesce into a single module. But, in Microservices Architecture they are spread into individual modules(microservice) which communicate with each other.

The communication between microservices is a stateless communication where each pair of request and response is independent. Hence, Microservices can communicate effortlessly. In the Microservice Architecture, the Data is federated. Each Microservice has its separate data store.



Microservice Challenges
MicroServices rely on each other, and they will have to communicate with each other. Compared to monolithic systems, there are more services to monitor which are developed using different programming languages. As it is a distributed system, it is an inherently complex model. Different services will have its separate mechanism, resulting in a large amount of memory for an unstructured data. Effective management and teamwork required to prevent cascading issues Reproducing a problem will be a difficult task when it's gone in one version, and comes back in the latest version. Independent Deployment is complicated with Microservices. Microservice architecture brings plenty of operations overhead. It is difficult to manage application when new services are added to the system A wide array of skilled professionals is required to support heterogeneously distributed microservices Microservice is costly, as you need to maintain different server space for different business tasks.

SOA vs. Microservices
SOA services are maintained in the organization by a registry which acts as a directory listing. Applications need to look up the services in the registry and invoke the service.

In another world, SOA is just like an orchestra where each artist is performing with his/her instrument while the music director gives instructions to all.

On the other end, Microservices is a form of service-oriented architecture style wherein applications are built as a collection of different smaller services instead of one software or application.

Microservices is just like a troupe where each dancer is independent and know what they need to do. So, if they miss some steps, they know how to get back on the correct sequence.

Here is a detailed comparison between SOA and Microservices:

Best Practices of Microservices Architecture

 * Separate data store for each Microservice


 * Keep code of a similar level of maturity.


 * Separate build for each Microservice


 * Always treat- servers as stateless.

Useful links:

 * Microservice Examples
 * Microservice Interview Questions
 * Microservice Interview Questions Resource
 * Flask Examples
 * NodeJS
 * Additional
 * Microservices Interview Questions With Answer

Summary

 * Microservices is a service-oriented architecture pattern wherein applications are built as a collection of various smallest independent service units.


 * Microservice Architecture is an architectural development style that allows building an application as a collection of small autonomous services developed for a business domain.


 * Monolithic architecture is like a big container in which all the software components of an application are clubbed into a single package
 * In a Microservice, every unit of the entire application should be the smallest, and it should be able to deliver one specific business goal
 * In Monolithic architecture, large code base can slow down the entire development process. New releases can take months. Code maintenance is difficult
 * Two types of Microservices are 1) Stateless 2) Stateful
 * Microservices rely on each other, and they will have to communicate with each other. Helps you to give emphasizes on a specific feature and business needs
 * Service-oriented architecture shortly known as SOA is an evolution of distributed computing based on the request or reply design model for synchronous and asynchronous applications
 * In SOA, software components are exposed to the outer world for usage in the form of services whereas Micro Service is a part of SOA. It is an implementation of SOA
 * Wiremock, Docker, and Hystrix are some popular Microservices Tools

Exercise
Create a web application that has the following requirements:


 * It should be based on at least 3 microservices
 * One service can be the Artefact repository from the last laboratory
 * It should have a Web UI
 * Use of templating engine is optional however it is recommended
 * Use JSON or XML for data interchange between services
 * Prefered JSON
 * Services should be RESTfull
 * Can use any programming language and/or platform (Java EE, Jersey, Flask, NodeJS etc.)
 * Recommend using Flask

NOTE: The completion of this exercise until next laboratory will be equivalent to the last 4 Homework assignments. It is advised for students who did not submit their assignments until now to complete at least this assignment.

Gabriel Iuhasz, 2019-12-16, [mailto:iuhasz.gabriel@e-uvt.ro iuhasz.gabriel@e-uvt.ro]