Microservices: What and Why?

Reading Time: 3 minutes

In this growing world, where number of users for softwares are increasing day by day, we need softwares that are easy to manage, easy to modify and easy to scale to handle the traffic. Several technologies, architectural patterns, best practices have emerged over these years. Microservices is one of those architectures that have emerged. In this blog, we will learn about microservices. So, let’s get started !

Why Microservices?

Even before knowing what is microservice it’s good to know why this concept of microservices architecture emerged.

Before microservices, the companies used monolithic architecture. In monolithic architecture there is one big system, just like a container that has all the software components.

Limitations of Monolithic
  • Inflexible – It is difficult to use different technologies in a monolithic.
  • Unreliable – A failure in one component is capable of bringing down the whole monolithic.
  • Unscalable –There is limitation to scaling as components must be scaled as a group. Also, it can only scale as far as the database allows.
  • Blocks Continuous Development – Sometimes simultaneous development and deployment is not possible.
  • Slow Development – Development is slow as building time is more.
  • Deep Coupling – Features of complex applications have tightly coupled dependencies

The above challenges were the main reasons that led to the evolution of microservices. 

What is Microservice?

Microservices, aka Microservice Architecture, is an architectural style that has multiple small autonomous services that together makes an application.

Some of the points to remember about microservice is :

  • Each small service serves a single functionality of the business domain. In other words, each service represents a logical part of domain.
  • All the services are independent
  • Services use API for communicating with each other. So, having API for each service is important.
  • All the services need to be deployed independently.
  • There is loose coupling between the different components of application, resulting in easy building, altering and scaling of the application.
  • Rapid deployments are possible.
  • In microservices there is no standard technology. A developer can choose the best tools as per their service requirement.
  • Developer or team can work independently of each other.

Pros of Microservices

Advantages of using Microservices
  • Independent Development : As each microservice serves a different purpose therefore they can be developed independently.
  • Independent Deployment : A microservice can be deployed when it is ready independently. It does not matter whether other microservices are ready for deployment.
  • Fault Isolation : If there is a fault in a single service then it does not propagate to other services.
  • Scalability : We can scale each service individually. If there is a need for scaling “Service A” as it is getting more traffic then it can be scaled without scaling the other services or whole application.
  • Increased Availability : Fault in one service does not affect the other, therefore availability is increased.
  • Mixed Technology Stack : Every service can use the technology that is best suited.

Cons of Microservices

  • Communication between Services : Since everything is now an independent service, you have to carefully handle requests traveling between your modules.
  • Deployment challenges : Having multiple services means multiple deployments. So here, managing multiple deployments is a crumblesome task in itself.
  • Global Testing : Testing an application as whole is difficult. So, you have to test each service individually for testing the whole application.
  • Cross-Service Refactoring : If a need arises that demands change in single service then it is easy but change in multiple services could be a problem. Consider a situation in which relationship between different service is misunderstood. So now if you have to refactor that would be difficult.

Also, you should focus on building reactive microservices. Just a microservice will do no good.

I hope this blog was helpful for you and you could get an idea about microservices.

Reference

Knoldus-blog-footer-image

Written by 

Muskan Gupta is a Software Consultant having almost 1-year experience. She has knowledge of languages like C, C++, Java and Scala. She is familiar with Object-Oriented Programming Paradigms and also has an interest in relational database technologies. Her hobbies include travelling, reading novels and listening to music.