What is Microservices?
Wikipedia definition says
But there is no official definition of Microservices by industry standards. It’s recent phenomenon in software industry to architect the new softwares which should be light weight, easier to deploy and scale, easier to refactor individually and could work independently.
We will not be covering this post in detail as compared to link I have posted here. Microservices are small services that can run independently, but can also easily communicate with other services.
Microservice Architecture vs Monolithic Architecture
In traditional monolithic architecture style, there is a single application with single code base. An application contains number of modules which are interrelated and can have external dependencies. It’s a multi-tier enterprise application and has been used to build software for long.
Microservice architecture style was born out of need to build an application that could easily be supported for mobile applications. Older style was not easy to support for mobile and new generation way to handling of data. Any large enterprise application can be easily built using microservices architecture style.
How to identify Microservice Architecture Pattern?
A simple ground rule of microservice architecture pattern is to build a standalone service that can be run without depending on any other service. That means for a large application can have more than one services talking to each other, communicating with their own databases, but still performing the business logic. Databases are used to ensure loose coupling of services.
A large enterprise e-commerce application can consist of following services
- Backend service REST API to manage data
- Account Service
- Shipment Service
- Inventory Service
- Runtime service to handle runtime and backend data to process business logic
- Logging service
- Error Handling service
- Session service
UI for the e-commerce application can be built independently to use backend services to show/edit data.
By standards, there are few rules to identify microservices patterns
- Decomposition by business capability
- Database per service pattern
- API gateway pattern
- Client-side discovery and Server-side discovery
Pros and Cons of Microservices
- Deployability – They can independently be deployed.
- Reliability – A fault in the service can only bring down that service, depending on handling in application, rest of the application can still be accessed.
- Scalability – Each microservice can be scaled depending on requirements using clusters and grids.
- Availability – Dispatching the patch or newer version of service requires less downtime compared to regular monolithic application.
- Management – Easier to manage
- Design and Development – Each service can be developed independently and helps developer to manage the service easily without worrying about other services.
- Performance – All services involved in application have to communicate with each other over network and that could hamper the performance.
- Testability – Automated tests are harder to manage and run.
- Memory usage – Possible duplicate data across services and lot of duplication in cache.
You can read more about Microservices at following links:
- Microservices by Chris Richardson
- Microservices by Martin Fowler
- Stackoverflow post about microservices