Robert C. Martin coined the term single responsibility principle which states “gather together those things that change for the same reason, and separate those things that change for different reasons.”
The microservices architecture takes this same approach and extends it to the loosely coupled services which can be developed, deployed, and maintained independently. Each of these services is responsible for a discrete task and can communicate with other services through simple APIs to solve a larger complex business problem. The services are independent of each other and run in their own processes.
The below diagram shows the difference between monolithic architecture and microservices architecture.
As we see from the above diagram, in the microservices architecture, the user interface is interacting with microservices that have their own independent storage as well. When the user interface calls a service, the business flow is executed independently of any data or logic contained within another microservice. This architecture has a lot of benefits, including the following:
- A smaller codebase: Each service is small and therefore easier to develop and deploy as a unit.
- The ease of an independent environment: With the separation of services, all developers work independently, deploy independently, and no one is concerned about dependencies.