header ads

Microservices architecture - Quick introduction

Microservice has become the most used architectural pattern for software system designing. This article gives you a quick and simple introduction to microservices architecture. Let's consider what are microservices and what is microservice architecture ;

Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are
  • Highly maintainable and testable
  • Loosely coupled
  • Independently deployable
  • Organized around business capabilities.
The microservice architecture enables the continuous delivery/deployment of large, complex applications. It also enables an organization to evolve its technology stack. definition by
We can summarize above definition as follows,
Microservice is an architecture which design software system as a collection of individual deployment components call microservices.

Before Microservices - Monolithic architecture

Before microservice architechure comes,  monolithic architechure was the standard for software system design. Monolithic architecture is simply the opposite of microservice. In monolithic architecture, all component of the system are interconnected as one unit (one code base) and packaged together. Lets understand monolithic architecture using a simple example.
Consider an online shopping mall like eBay or amazon. It has 3 major services
  • Product service (which provide all product details with pricing)
  • Shopping cart service (which provides all payment related services)
  • Customer services (which provides solutions for customer issues)

In monolithic archtechture, we design above mentioned online store with these major components as one unit. That means simply a single codebase and a single database. This approach is OK for a small system. But when the system starts to expand, the code get more complex and more developers will work with the system at same time. Now this system starts to effect from following issues.
Since the all services are under one package and depends on each other, if one service goes down, whole system goes down. (i.e if the customer service component goes down due to a bug, usually we have to be able to purchase items without any issue. But due to the monolithic architecture of the system, the whole system become useless)
Also if one service needed to be upgrade with some feature or bug fix, whole system code has to be recompiled and deploy.

When systems expanding, its very difficult to scale and load balance.
Also it is not possible to use different frameworks or languages for each service component as they are all interconnected as one package. (i.e. if other 2 services has been written in java and the shopping cart service can be written in python with advanced features than java, it cannot be done 
and have to write using java too)

Microservice architecture

Microservice architecture has been implemented to avoid above drawbacks. Lets consider the same online store example with microservice architecture.

  • Product service, shopping cart service and customer service has its own separate service components.
  • All services communicate each other through rest APIs.
  • Each microservice has its own load balances therefore less scaleability issues.
  • Since all 3 services are independent and has its own frameworks and data, each module can be developed using different languages.
Refer above diagram and compare it with monolithic architecture diagram to get a clear idea.

Structure of microservice architecture

Above diagram shows the basic mechanism of a microservices based system. But microservice architecture contains more components. Following diagram contains them all.
Lets identify all of the components in brief

  • client - user of the system from any platform (mobile, PC etc.)
  • identity provider - authenticate user requests and pass them to the API gateway
  • API gateway - received authenticated requests and send them to the desired microservice to process
  • http REST or message bus - allows communication between microservices
  • CDN (content delivery networks ) - distributed network of proxy servers of system
  • remote service - enables the remote access for the information
  • static content - houses all the content of the system
  • service discovery - act as a guide to find the road to the communication between microservices and networks

NOTE: If one user request may need to process from all microservices to archive final output. In that case, each microserviice process its specific tasks by communicating each other and send their outputs to the API gateway, then the API gateway aggregate all of them and send back to the client as a single solution.

Advantages of microservices

  • Idependant deployment
  • Mixed technology stack
  • Independent development
  • Easy fault isolation
  • Granular scaling

This is the basic functionality of a microservice architecture. Hope you can understand how microservices behave and what are the differences in monolithic and microservice architectures. In next tutorial we are going to consider an example of microservices in java spring boot. Like our facebook page to stay upto date with our latest tutorials.

Post a Comment