P2: Need for MicroService

P2: Need for MicroService
Photo by Jiayou Sun / Unsplash

Hopefully you are coming from the previous post, if that is case you've probably figured out what a MicroService is. Let's look at the advantages of MicroServices using some real-world problem statement.

In case you are wondering what MicroServices are! You can read the previous part of this article What is MicroService

1. Maintainability

Assume we have an application with, say, some of the following features.

  1. Authentication
  2. Feature A
  3. Feature B
  4. Feature C

Now, in the previous technique, we would start our implementation by creating all the features in the same code base. Right?
Assume we have a problem with feature B, and the developer who needs to solve it must grasp the complete source.

However, if we have

  1. Authentication
  2. Feature A
  3. Feature B
  4. Feature C

We would separate the code bases for all of these different features using the microservices strategy. So we can imagine these services are separate servers and dedicated to perform a specific task. Take a look at Fig 1.

MicroService Architecture - Fig 1

In this case, if Feature B is having a problem, you don't need to know the complete codebase to solve Feature B. However, you just need to review the codebase for Feature B only, and you may expect that all other services are functioning normally.

2. More than one programming languages

As microservices are independent servers, and each server is dedicated to completing a certain task solely, there is no strict requirement that we need to utilise the same programming language to implement everything.

Microservices allows us to use numerous programming languages for the various services that we are creating. You can have your architecture like the following,

  1. Java for the Authentication server
  2. NodeJS for file real-time Messaging server
  3. Go for Feature B
  4. Maybe Rust for Feature C
Ability to use multiple Programming Languages - Fig 2

You have the option of selecting the optimal programming language to accomplish specific features. Also, if you have teams with diverse tech stacks, you can start working on Feature B with the Python team while the NodeJS team is engaged developing Feature A, which enhances project delivery.

3. You can use more than one databases

As we learned in microservice, we can develop independent services using several programming languages. Similarly, numerous databases can be used. Each microservice can use its own preference as needed.

Use of multiple databases to build one software - Fig 3

As a result, if you require a certain database for a given use case, you are not required to use the same database within the same codebase. Various databases are straightforward to link from different programming languages. Also some database needs to have specific approaches in order to be efficient.

In the case of monolithic applications, you need to have the same code base refactored or have some helper functions that will be specifically for connecting to the database, but at the end it increases the server's complexity, right?

But in the case of microservices, we can use the separate code base concept to reduce the complexity and make the code much simpler for us, to debug or implement new things.

4. Self contained

So, using this microservice design, we've now separated all of these distinct elements and wrapped them up in their own tiny individualised services. The most important thing to grasp here is that each of these services is completely self-contained.

MicroServices can have their own databases - Fig 4

So this service has all of the code required to make feature a work properly.
It comes with its own middleware and router.  And, perhaps shockingly, it will have its own database over here as well.  The advantage of this technique is that if, for whatever reason, every other feature or every other.

A service within our programme fails or mysteriously disappears, and a piece of our software is disabled. As the service, say, is completely self-contained and does not require any additional software, it will continue to function normally. any other service to function properly

In the next part we will find some of the big challenges of MicroServices. See you there!