Microservice is a software architecture that is gaining more and more attention.

But what does it really mean? What kind of architecture can be called microservices?

There are many articles on the Internet, but they are too complicated for beginners to understand. In my opinion, the concept is actually very simple and can be understood in layman’s terms.

Microservice

1. Monolithic Software

To understand microservices, you first need to understand the evolution of software architecture.

In the early days of software, all functions were written together in what was called monolithic software.

monolithic software

The whole software is a single whole, as if it were an integrated machine.

As you can imagine, the more functions the software has, the more complex the monolithic architecture becomes, and many drawbacks are exposed.

  1. All functions are coupled together and affect each other, which is ultimately difficult to manage.
  2. Even if only one line of code is modified, the whole software has to be rebuilt and redeployed, which is very costly.
  3. Because the software is made into a whole, it is impossible to develop and test each function individually, but only as a whole, resulting in the need to use the waterfall development model.

monolithic software drawbacks

In short, large software with monolithic architecture is not only slow to develop, but also creates complex code that is difficult to maintain and upgrade, and becomes a heavy burden for programmers.

2. Service Oriented Architecture

In order to solve these problems, it has been proposed for a long time that the coupling of code must be broken down, and the monolithic architecture must be split up into individual functional units.

About 20 years ago, with the emergence of the Internet, functional units could be provided in the form of remote “services”, and the “service-oriented architecture” (SOA) was born.

SOA

A service is a program that runs uninterrupted in the background and provides a certain function. The most common service is a web service, which provides web access to the outside world through port 80.

A “service-oriented architecture” is a large monolithic program split into individual services, i.e. smaller programs. Each service is a separate functional unit that performs a different function, and the services are connected to each other by a communication protocol.

SOA

This architecture has many advantages.

  1. Each service has a single function, which is equivalent to a small software and is easy to develop and test.
  2. Each service operates independently, simplifying the architecture and improving reliability.
  3. Code reuse is encouraged and supported, and the same service can be used for multiple purposes.
  4. Different services can be developed and deployed separately, making it easy to upgrade.
  5. Good scalability, can easily add machines and functions, and withstand high loads.
  6. It is not easy to have a single point of failure. Even if one service fails, it will not affect other services.

Unlike monolithic architectures, service-oriented architectures are language-insensitive; different services can be developed using different languages and tools and may need to be deployed on different systems and environments.

This means that service-oriented architectures run by default on different servers , each providing one service, with multiple servers working together to form a complete web application.

3. Microservices

In 2014, Docker came along and revolutionized the face of software development. It allows programs to run in containers, each of which can be set up separately as a runtime environment, and takes up very few system resources.

Microservices

Obviously, containers can be used to implement a “service-oriented architecture”, where each service no longer occupies a server, but a container.

This eliminates the need for multiple servers, and in the simplest case, runs multiple containers natively, using only one server to implement a service-oriented architecture, which was not possible before. This implementation is called microservices.

Monolith vs Microservices

Simply put, microservices is a service-oriented architecture using container technology. It still uses “service” as a functional unit, but it is a lightweight implementation that does not require a new server, but a new container (a process), hence the name “microservice”.

A microservice is a separate process. This process can run locally, on another server, or in the cloud (e.g., Cloud Services and Cloud Functions FaaS).

It has the same characteristics as a service-oriented architecture, but because it is more lightweight, the decoupling and servitization of functions can be done more thoroughly. Moreover, it can be standardized so that the same container will have the same result no matter where it is run, so there are many SaaS products on the market that offer standardized microservices.

It is because of these outstanding benefits of microservices that it has become so popular in the past few years. Together with container technology and cloud services, it is sure to play an increasingly important role in the future of software development.

Reference https://www.ruanyifeng.com/blog/2022/04/microservice.html