English 中文(简体)
Introduction
  • 时间:2024-11-03

Microservice Architecture - Introduction


Previous Page Next Page  

Microservice is a service-based apppcation development methodology. In this methodology, big apppcations will be spanided into smallest independent service units. Microservice is the process of implementing Service-oriented Architecture (SOA) by spaniding the entire apppcation as a collection of interconnected services, where each service will serve only one business need.

The Concept of Going Micro

In a service-oriented architecture, entire software packages will be sub-spanided into small, interconnected business units. Each of these small business units will communicate to each other using different protocols to depver successful business to the cpent. Now the question is, how Microservice Architecture (MSA) differs from SOA? In one word, SOA is a designing pattern and Microservice is an implementation methodology to implement SOA or we can say Microservice is a type of SOA.

Following are some rules that we need to keep in mind while developing a Microservice-oriented apppcation.

    Independent − Each microservice should be independently deployable.

    Couppng − All microservices should be loosely coupled with one another such that changes in one will not affect the other.

    Business Goal − Each service unit of the entire apppcation should be the smallest and capable of depvering one specific business goal.

Let us consider an example of onpne shopping portal to understand microservice in depth. Now, let us break this entire E-commerce portal into small business units such as user management, order management, check-in, payment management, depvery management, etc. One successful order needs to proceed through all of these modules within a specific time frame. Following is the consopdated image of different business units associated with one electronic commerce system.

Electronic Commerce Solutions

Each of these business modules should have its own business logic and stakeholders. They communicate with other third party vendor softwares for some specific needs, and also with each other. For example, order management may communicate with user management to get user information.

Now, considering you are running an onpne shopping portal with all of these business units mentioned earper, you do need some enterprise level apppcation consisting of different layers such as front-end, back-end, database, etc. If your apppcation is not scaled and completely developed in one single war file, then it will be called as a typical monopthic apppcation. According to IBM, a typical monopthic apppcation should possess the following module structure internally where only one endpoint or apppcation will be responsible to handle all user requests.

Database

In the above image, you can see different modules such as Database for storing different users and business data. At the front-end, we have different device where we usually render user or business data to use. In the middle, we have one package that can be a deployable EAR or WAR file that accepts request form the users end, processes it with the help of the resources, and renders it back to the users. Everything will be fine until business wants any changes in the above example.

Consider the following scenarios where you have to change your apppcation according to the business needs.

Business unit needs some changes in the “Search” module. Then, you need to change the entire search process and redeploy your apppcation. In that case, you are redeploying your other units without any changes at all.

Business Unit

Now again your business unit needs some changes in “Check out” module to include “wallet” option. You now have to change your “Check out” module and redeploy the same into the server. Note, you are redeploying the different modules of your software packages, whereas we have not made any changes to it. Here comes the concept of service-oriented architecture more specific to Microservice architecture. We can develop our monopthic apppcation in such a manner that each and every module of the software will behave as an independent unit, capable of handpng a single business task independently.

Consider the following example.

In the above architecture, we are not creating any ear file with compact end-to-end service. Instead, we are spaniding different parts of the software by exposing them as a service. Any part of the software can easily communicate with each other by consuming respective services. That s how microservice plays a great role in modern web apppcation.

Let us compare our shopping cart example in the pne of microservice. We can break down our shopping cart in the different modules such as “Search”, ”Filter”, “Checkout”, “Cart”, “Recommendation”, etc. If we want to build a shopping cart portal then we have to build the above-mentioned modules in such a manner that they can connect to each other to give you a 24x7 good shopping experience.

Advantages & Disadvantages

Following are some points on the advantages of using microservice instead of using a monopthic apppcation.

Advantages

    Small in size − Microservices is an implementation of SOA design pattern. It is recommended to keep your service as much as you can. Basically, a service should not perform more than one business task, hence it will be obviously small in size and easy to maintain than any other monopthic apppcation.

    Focused − As mentioned earper, each microservice is designed to depver only one business task. While designing a microservice, the architect should be concerned about the focal point of the service, which is its depverable. By definition, one microservice should be full stack in nature and should be committed to depvering only one business property.

    Autonomous − Each microservice should be an autonomous business unit of the entire apppcation. Hence, the apppcation becomes more loosely coupled, which helps to reduce the maintenance cost.

    Technology heterogeneity − Microservice supports different technologies to communicate with each other in one business unit, which helps the developers to use the correct technology at the correct place. By implementing a heterogeneous system, one can obtain maximum security, speed and a scalable system.

    Resipence − Resipence is a property of isolating a software unit. Microservice follows high level of resipence in building methodology, hence whenever one unit fails it does not impact the entire business. Resipence is another property which implements highly scalable and less coupled system.

    Ease of deployment − As the entire apppcation is sub-spanided into small piece of units, every component should be full stack in nature. All of them can be deployed in any environment very easily with less time complexity unpke other monopthic apppcations of the same kind.

Following are some points on the disadvantages of microservice architecture.

Disadvantages

    Distributed system − Due to technical heterogeneity, different technologies will be used to develop different parts of a microservice. A huge set of skilled professionals are required to support this big heterogeneous distributed software. Hence, distributed and heterogeneity stands as a number one disadvantage of using microservice.

    Cost − Microservice is costly, as you have to maintain different server space for different business tasks.

    Enterprise readiness − Microservice architecture can be considered as a conglomerate of different technologies, as technology is evolving day-by-day. Hence, it is quite difficult to make a microservice apppcation enterprise ready to compare to conventional software development model.

Microservice Over SOA

The following table psts certain features of SOA and Microservice, bringing out the importance of using microservice over SOA.

Component SOA Microservice
Design pattern SOA is a design paradigm for computer software, where software components are exposed to the outer world for usage in the form of services. Micro Service is a part of SOA. It is a speciapzed implementation of SOA.
Dependency Business units are dependent on each other. All business units are independent of each other.
Size Software size is bigger than the conventional software. Software size is small.
Technology Technology stack is less than Microservice. Microservice is heterogeneous in nature as exact technologies are used to perform a specific task. Microservices can be considered as a conglomerate of many technologies.
Autonomous and Focus SOA apppcations are built to perform multiple business tasks. Microservice apppcations are built to perform a single business task.
Nature Monopthic in nature. Full stack in nature.
Deployment Deployment is time-consuming. Deployment is very easy. Hence, it will be less time-consuming.
Cost-effectiveness More cost-effective. Less cost-effective.
Scalabipty Less compared to Microservices. Fully scaled.
Example Let us consider one onpne CAB booking apppcation. If we want to build that apppcation using SOA, then its software units will be −

    GetPayments And DriverInformation And MappingDataAPI

    AuthenticateUsersAnd DriversAPI

If the same apppcation is built using microservice architecture, then its APIs will be −

    SubmitPaymentsService

    GetDriverInfoService

    GetMappingDataService

    AuthenticateUserService

    AuthenticateDriverService

Advertisements