What Are Microservices?
Many people have many perspectives on Microservices, and there are many definitions. I recommend, rather than going by the definition, go by characteristics.
Join the DZone community and get the full member experience.Join For Free
Although the question is simple, it is tough to answer, as 'Microservice' does not have any de-facto standard. As a result, many people have many perspectives on Microservices, and there are so many definitions.
The compelling definition is:
Microservices are a suite of services where each service is bounded by a bounded context and can run, deploy, and scale independently, without impacting other services.
So, to make the above statement correct in reality, organizations that have adopted Microservices follow few common characteristics, so:
I recommend, rather than going by the definition, go by characteristics.
11 Characteristics of a Successful Microservices Architecture
1. Componentization of Services:
Service can be upgraded, evolved, deployed, scalable, tested independently.
2. Database Per Core Services:
Take out the coupling from the database and make it private to core services, and create an API contract by which other services get data.
3. Test Cases Are the First-class Citizen:
As MS is a collaboration of multiple services, Unit tests and Integration tests are needed often to identify issues. Fail fast strategy is key to success, so there's the need for full Unite test case and integration test coverage with automation.
4. CI/CD Pipeline and Automation:
To become a success, we need CI/CD pipeline and provision to deploy in UAT, SIT, and may be automated deployment to PROD as well. Also If using PAAS, or containerization to treats resources like cattle, not pets, we can spin servers on the fly for X-axis scaling
5. You Build It, You Run It Strategy:
Make sure teams are a mixed bag; Agile teams UI, Backend, DBA, QA, and the team is responsible for implementing a business capability, like Registration Team or Login Team, Order Team, Payment Team, etc. One Scrum may handle Aggregator and core services for that functionality based on organization and team strength, but one feature is that team is the sole owner of that feature: all bugs, support, deployment, delivery, database tuning, testing will be done by that team.
6. Strategy for Failure is a Must:
Microservice architectures dealing with a chain of services call over the network which is not in the team's control, so it is bound to fail, but we create MS for high availability. So a failure strategy is a must, not a good to have kind of things, so always design Plan A, B, C, D for failure, and lastly, fallback.
7. No Single Point of Failure:
Never, ever design a component that can't be scalable through X-axis. So, replication is a must for MS; use CAP theorem for your business needs, whether it is the service, database, Cache, config, Load balancer, or any component.
8. Reduce Chattiness by Aggregator:
As microservices over network call and a capability spans multiple services design an Aggregator which collects information from core services and returns UI specific response. Use Aggregator carefully; it might cause a God Service antipattern.
9. Tracing and Logging:
With microservices over network calls and a capability that spans multiple services, think about how developers debug if something goes wrong. So use the Tracing mechanism, also as MS using X-axis scaling, it is not possible to check every server. Rather, we need a log aggregator like ELK or Splunk so we are using a correlated id developer to trace the call.
10. Smart Endpoint Dumb Pipe:
Pipe means carrier of instructions, i.e., the network only carries the payload all logic in the MS itself, unlike Service Bus, where middleware did all that stuff for you!!
11. Externalization of Configuration:
Configuration must be extracted out from MS so we can change them without restarting the services, it helps to achieve high up time for the service.
If the above characteristics are present, we can safely say it is Microservice. The missing of one or many characteristics means that is not a Microservice, but we can say they tend to achieve Microservices.
Published at DZone with permission of Shamik Mitra, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.