I have a spring-boot application named ‘RestAPI‘ which acts as backend service for my UI.
The RestAPI has become a bit complex… so I need to break it down in microservices.
The RestAPI has following functionalities I would like to convert to microservices:
- Service 1 – Service for basic operations of Protocol 1.
- Service 2 – Service for basic operations of Protocol 2.
- Service 3 – Service for complex operations of Protocol 1.
- Service 4 – Service for complex operations of Protocol 2.
Note – Just a thought… not finalized if I will follow the above mentioned steps.
But need microservices that is final.
The main question is…
Currently I am using 1 docker container for the RestAPI application.
So.. if I break the RestAPI into microservices will it be a good approach to run all the microservices in one docker container ?
If yes.. how can I achieve it using 1 Docker file or multiple Docker files ?
If no.. why is it not feasible ?
2
Answers
Microservices offer several advantages, such as agility, flexible scaling, continuous deployment, maintainability, testability, independent deployability, technology flexibility, and high reliability. They promote agile ways of working, enabling teams to experiment with new features and allowing for fast and easy independent deployment of individual features. Additionally, microservices provide technology flexibility, high reliability, and increase team autonomy.
However, if all microservices run in the same container, they will use the same resources, which can result in something like a monolithic application. To avoid this, each microservice must have its own CPU, memory resources, database, storage, etc. While it is possible to run multiple microservices in the same container, it is not recommended.
To manage each microservice independently, each one should have its own Docker container, which can be orchestrated using Docker Compose or Kubernetes. To achieve this, a Dockerfile must be created for each microservice. The services can also be deployed on AWS Lambda, GCP Cloud Run, App Engine, and other platforms.
Source: https://mintymint.net/blog/tech/microservices-vs-monolithic-software-architecture-guide/
Here is some more useful information:
besides the Advantage, if you are curious to run all your Service In One Container.
FYI:- Not Advisable to use in PROD
Start.sh