- Service that solves single business purpose. (S of SOLID principal). Keep slicing till you get the answer "nothing" for question "What else it is doing?"
- Can be developed independently
- Can be deployed independently.
- Decoupled from rest of the world :)
Why microservice
- Since developed independently development is faster.
- Since deployed independently CI/CD is easy and so is agile and TDD etc.
- In a way more secure as loophole in one functionality can not be exploited for other functionalities
- Uptime is increased as problem is localised.
- Scalability is better as scaling up or out is done for specific service that really requires it and not for entire monolith.
- Greater flexibility to development teams in terms of choice of technology etc.
- In terms of cloud more appropriate type of environment can be selected for deployment (say type of EC2 instance)
Features of MSA
- High cohesion
- Autonomous
- Business Domain Centric
- Resilient
- Observable
- Automation
Components involved (with example in Spring cloud)
- Service
- Service Registry and locator (Netflix Eureka)
- API Gateway and router (Netflix Zuul)
- Load Balancer (Netflix Ribbon)
- Fault Tolerance (Netflix Hystrix)
- Nodes that serve the content (Spring Boot)