How small should the microservice be for applications?
What is microservice?
“Microservice Architecture” has no concrete definition but we can describe it as a way of designing software applications that have independently deployable services, intelligence in the endpoints, and decentralized control of languages and data.
How small the microservice be?
A microservice should just handle one purpose and more specifically one thing. This one thing or one purpose can have a lot of meanings.
Many microservice suggest that each microservice can be as small as a single function. Imagine a single function microservice that needs an independent deploy cycle, independent logging, independent security, and monitoring, etc. These types of architecture will be too much for any application.
If we consider a microservice that serves one task as a unit is a good candidate for microservice. Let’s consider an example. Imagine we want to write a data migration application from a source application to a destination application. How can we split the tasks into multiple microservices?
A migration application has the following three tasks:
- Extract data from the source application
- Transform the source data to the destination data format
- Load the transformed data to the destination application
If we consider the above three tasks as three independent microservice, then it becomes a good for microservice architecture.