Microservice to the Rescue
Microservice membereskan semua monolith problem
In the previous discussion, it has been explained that to solve all problems in monolith or hexagonal architecture is to use the microservice approach. But what are microservices exactly? Unfortunately, names do not always provide insight or deep meaning. So we must find the answer from a lot of definitions of microservice expressed by experts and practitioners in the world of software development.
The definition of microservice is usually used as a reference origin from the founder of Netflix, a company that has successfully implemented microservice. He explained that microservice is a service-oriented architecture composed of loosely coupled elements that have bounded contexts. This explanation aligns with the explanation expressed by Martin Fowler, the Father of Microservice.
Scale Cube and Microservice
A more in-depth explanation of the microservice can be understood from a book titled “The Art of Scalability. The book explains that the way to scale up your application can be done in three ways as shown below.
X-direction, usually do to scale up the monolith system. A load balancer is needed to split the number of requests that enter the system and distributed them to all copies of the application. This is the best way to increase application capacity and availability.
Y-direction, the way to scale up is doing the same as the X-direction, by creating multiple instances and dividing the load using a load balancer. However, in the y-direction, each instance of the application will only serve a group of data. Suppose we will divide the request based on the user as shown below.
The technique to scale up in the Y-direction is the best way to improve application performance in handling of the increasing number of transactions and data.
Z-direction, a way to scale up by dividing monolith applications into several smaller services based on functionality. The x-direction and y-direction cannot yet be a solution to the problem of increasing the amount of code and complexity, with this z-direction these problems can be solved properly.
Thus, the best solution is as illustrated by the following image.
Based on Martin Fowler’s and other expert’s definitions, a microservice system should have some characteristics below :
- Each service is built as a light-weight service, independent from each other, and loosely-coupled business unit,
- Because each service is responsible for a single part of the functionality (business capability) and does it well, this will make better ownership of the service,
- Each service has itself codebase, managed and developed by a small team (mostly in an agile environment),
- We can pick the best technology stack for every service (no need to stick into one framework throughout the entire application),
- Each service has itself DevOps plan (test, release, deploy, scale, integrate, and maintain independently),
- Each service is deployed in a self-contained environment,
- Communication between service with each other by using well-defined APIs (smart endpoints) and simple protocols like REST over HTTP (dumb pipes).
- Each service is responsible for persisting data and keeping external state (Only if multiple services consume the same data, such situations are handled in a common data layer)
If we implement the microservice, then this is how RSMS now look alike:
When we decide to move to a microservice system, there is something we need to pay attention to in terms of the operational side. For the real success of microservices architecture, significant investments will be required to handle cross-system concerns, such as:
- Service replication is a mechanism that services can easily scale based upon metadata
- Service registration and discovery is a mechanism to enable service lookup and finds the endpoint for each service.
- Service monitoring and logging is a mechanism to aggregate logs from different microservice and provide a consistent reporting
- Resiliency is a mechanism for services to automatically take corrective actions during failures
- DevOps is a mechanism for handling continuous integration and deployment (CI and CD)
- The API gateway is a mechanism for providing an entry point for clients
Stay tuned, because in the future we will more talk and deep about this microservice architecture.